Commit Graph

21 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
Tzu-ping Chung cd01e4fd8f Remove pkg_resources usages from utils modules
Relevant functionalities are moved into pip._internal.metadata.
2021-12-04 17:57:33 +08:00
Jon Dufresne 6a6561c2cb Move many type comments to annotations
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
2021-08-10 07:12:32 -07:00
Andrey Bienkowski 622f104694 Use f-strings for formatting
suggested by pyupgrade --py36-plus
2021-03-30 15:48:27 +03:00
Jon Dufresne a9d4446dc4 Blacken src/pip/_internal/utils directory 2021-02-21 07:24:35 -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 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
Tzu-ping Chung 5fac450375
Merge pull request #9368 from jdufresne/ensure
Remove unnecessary uses of six.ensure_(binary|str|text)
2021-02-18 20:40:21 +08:00
Jon Dufresne 156886c144 Use dict and set comprehension where available 2020-12-27 08:49:32 -08:00
Jon Dufresne c115cdc81a Remove unnecessary uses of six.ensure_(binary|str|text)
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.
2020-12-27 07:56:18 -08: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 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Chris Hunt 8259528ed9 Simplify and optimize getting zip subdirs
Since we only care about the first path part, we can stop at 1 split. We
do not need a list, so the unnecessary conversion has been dropped.
2020-07-03 09:02:30 -04:00
Pradyun Gedam e648e00dc0
pip is spelt all-lowercase 2020-02-18 10:55:16 +05:30
Deepak Sharma d31cf696e8 string_formatting 2020-01-30 20:33:00 +05:30
Chris Hunt 33043ba22f Use pkg_resources.Distribution derived from wheel directly
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.
2020-01-05 10:57:14 -05:00
Chris Hunt ed65393840 Extract reading wheel file from wheel_metadata into separate function 2020-01-04 20:50:17 -05:00
Chris Hunt ae34781826 Parameterize wheel file path for metadata extraction 2020-01-04 20:50:17 -05:00
Chris Hunt b263fcc105 Move parse_wheel and supporting functions to utils.wheel
In order to parse metadata from wheel files directly we want to reuse
parse_wheel. Moving it out helps avoid creating an unnecessary
dependence on operations.install.wheel.
2020-01-04 23:11:51 +01:00