In autocompletion.py, the should_list_installed boolean expression was
flipped to workaround upstream black bug:
https://github.com/psf/black/issues/1629
The bug makes black fail to stabilize formatting when the list isn't the
last piece of the expression.
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
Removes the vendored contextlib2.
ExitStack and suppress are available from stdlib contextlib on all
supported Python versions.
The nullcontext context manager which isn't available in Python 3.6, but
the function is simple to implement. Once Python 3.6 support is dropped,
so too can the compat shim.
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
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.