As the class name starts with "Test", pytest interprets it as a test
case, but it is not one. Further, due to its `__init__` method, pytest
emits the following warning:
.../pip/tests/lib/__init__.py:141: PytestCollectionWarning: cannot
collect test class 'TestData' because it has a __init__ constructor
For additional information on pytest discovery, see:
https://docs.pytest.org/en/latest/example/pythoncollection.html
Use the tool com2ann to automatically convert most type comments to type
annotations. Some type comments continue to exist where any work beyond
the automatic conversion was required (for example, additional
formatting or circular references).
For additional information on the com2ann tool, see:
https://github.com/ilevkivskyi/com2ann
The typing module has been available since Python 3.5. Guarding the
import has been unnecessary since dropping Python 2.
Some guards remain to either:
- Avoid circular imports
- Importing objects that are also guarded by typing.TYPE_CHECKING
- Avoid mypy_extensions dependency
The stdlib module has been available since Python 3.5 and the
TYPE_CHECKING constant has been available since 3.5.2.
By using stdlib, this removes the need for pip to maintain its own
Python 2 typing compatibility shim.
https://www.python.org/dev/peps/pep-3102/
Replaces the pattern: self.name = kwargs.pop('name')
Keyword-only arguments offer some advantages:
- In the event of a typo or misuse, a more informative error is
presented to the programmer.
- More self documenting and makes interfaces more explicit.
- They more easily allow explicit typing.
Adding types to ConfigOptionParser required changing some call sites to
pass arguments without using a dict due to mypy bug:
https://github.com/python/mypy/issues/9676
Now that Python 2 is not supported, the bytes/str boundaries are more
clear and explicit. Using six.ensure_* methods for backwards
compatibility is no longer necessary as the types are known and verified
using mypy.
One exception is tests/lib/wheel.py which allows tests to pass test
setup data as either bytes or str.
The module operations.install.wheel also remains untouched as it is
especially delicate to bytes/str mixups and the current version is
working.
Use pyupgrade to convert simple string formatting to use f-string
syntax. pyupgrade is intentionally timid and will not create an f-string
if it would make the expression longer or if the substitution parameters
are anything but simple names or dotted names.
This implementation uses tests.lib.make_wheel, which allows more
flexible wheel configuration in a more structured way.
Output-wise this should be almost identical to the previous
implementation, with the following exceptions:
* Metadata-Version is bumped from 2.0 (previous implementation) to 2.1
(from make_wheel).
* Fields previously supplied as UNKNOWN are now omitted since they are
not significant to tests.
* The DESCRIPTION file is omitted (since the description field is now
missing, see previous point).
By default, make_archive uses str paths on Python 2, which causes it to
skip files with unencodable names. By passing in a unicode base_dir
explicitly, it is smart enough to use unicode all the way down instead.
We now extract all metadata files from the wheel directly into memory
and make them available to the wrapping pkg_resources.Distribution via
the DictMetadata introduced earlier.
Previously we were copying an existing wheel to a file with a
different distribution name. When using stricter metadata parsing this
would fail, so now we use a more conformant dummy wheel function.