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.
Previously we were restricting to a single .dist-info directory anywhere
in the unpacked wheel directory. That was incorrect since only a
top-level .dist-info directory indicates a contained "package". Now we
limit our restriction to top-level .dist-info directories.
* Add option to silence warnings related to deprecation of Python versions
* Move skip_if_python2 and skip_if_not_python2 decorator declaratios to test/lib/__init__.py and use them in test_warning.py
* Add tests to ensure that python version deprecation warning is shown correctly and can be silenced by a flag.
* Add new test to ensure that --no-python-version-warning flag does nothing if python version is not 2