Commit Graph

26 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
Lukas Geiger 3d6b0be901 Remove outdated noqa comments 2023-09-22 01:28:54 +01:00
q0w 3820b0e52c
Replace Iterator[T] with Generator[T,None, None] (#11007)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2022-04-09 16:11:58 +01:00
Harutaka Kawamura df98167fe5
Complete type annotations in `pip/_internal/cli` (#10169) 2021-07-23 11:39:53 +08:00
Diego Ramirez 1e016d2994
Convert type hint comments into annotations
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-06-07 21:19:23 +08:00
Jon Dufresne 63ea2e8c08 Handle several mypy TODO comments and exceptions
Remove mypy exceptions that are straightforward to remove.
2021-02-22 16:53:54 -08:00
Jon Dufresne 83c596ff70 Blacken src/pip/_internal/cli directory
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.
2021-02-21 07:29:15 -08:00
Jon Dufresne 0945809afc Remove typing.TYPE_CHECKING guards
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
2021-02-19 18:34:21 -08:00
Jon Dufresne d9b5525193 Prefer stdlib contextlib over contextlib2 when available
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.
2021-02-19 04:13:33 -08:00
Jon Dufresne a6392bd62e Replace pip._internal.utils.typing with stdlib typing
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.
2021-02-18 19:09:13 -08:00
Jon Dufresne 8683413501 Use keyword-only arguments
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
2021-01-29 21:15:36 -08:00
Paul Moore 6739f56351 Use our own copy of strtobool, rather than the one from distutils 2021-01-20 15:42:29 +00:00
Jon Dufresne cdcf74fb8e Use f-strings for simple string formatting
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.
2020-12-25 16:21:20 -08:00
Jon Dufresne c148bcc1aa Use short Python3 super() syntax 2020-12-24 15:11:51 -08:00
Jon Dufresne f32adaf09b Remove __future__ imports
Unnecessary since dropping Python 2.
2020-12-24 08:38:09 -08:00
Hugo van Kemenade add5cfa514 Replace compat shim with shutil.get_terminal_size() 2020-12-22 22:41:58 +02:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Noah Gorny 5cfd8a7c3e Handle case of list default values in UpdatingDefaultsHelpFormatter
Happens because we pass a list from --extra-index-url
2020-12-04 15:29:50 +02:00
Noah Gorny 8f821866d6 Redact auth from URL in UpdatingDefaultsHelpFormatter 2020-11-25 21:18:01 +02:00
Nguyễn Gia Phong 2439d80a83 Allow specifying verbose/quiet level via config file and env var 2020-07-28 10:11:18 +07:00
Jason R. Coombs 3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Deepak Sharma d31cf696e8 string_formatting 2020-01-30 20:33:00 +05:30
Maxim Kurnikov 3692097cca add per-file disallow_untyped_defs=False, and set it to True globally 2019-09-29 23:31:15 +02:00
Pradyun Gedam e938d439a2
Switch to a global variable for exit status codes 2018-09-20 11:18:17 +05:30
Pradyun Gedam b13cee6388
Merge branch 'master' into refactor/pip-cli-subpackage 2018-07-30 09:52:18 +05:30
Pradyun Gedam 8314dcb7d0
Rename baseparser to parser 2018-07-30 09:35:08 +05:30
Renamed from src/pip/_internal/cli/baseparser.py (Browse further)