Commit Graph

79 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
Paul Moore c7daa07f6a Reword the check for no hashes 2023-06-27 14:47:39 +01:00
Paul Moore 5168881b43 Implement PEP 714 - rename dist-info-metadata 2023-06-08 10:10:15 +01:00
Paul Moore 232cc9dd52 Parse hash data before passing to MetadataFile 2023-06-08 10:09:09 +01:00
Paul Moore 8f89997d0d Fix types to be 3.7-compatible 2023-06-07 21:11:34 +01:00
Paul Moore 6c3db098ff Fix parsing of JSON index dist-info-metadata values 2023-06-07 20:58:40 +01:00
Stéphane Bidoul 89e7208784
Improve readability
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2023-04-08 10:45:07 +02:00
Stéphane Bidoul d4274db727 Simplify assertion 2023-04-08 00:08:17 +02:00
Stéphane Bidoul 540f8fbb6d Keep empty hash, as before 2023-04-07 23:49:38 +02:00
Stéphane Bidoul 48152bb2e1 pep 658 hashes are not URL fragment hashes 2023-04-07 23:44:22 +02:00
Stéphane Bidoul 6e5d467822 Various fixes to the link hash parser 2023-04-07 23:07:01 +02:00
Tzu-ping Chung 0233bf2757 Merge link_hash back into _hashes
Commit bad03ef931 introduced the new
link_hash attribute that holds the link's hash info, but that attribute
does the same thing as _hashes, and some existing usages still populate
that old attribute. Since the plural variant covers more use cases (a
file can be hashed with multiple algorithms), we restore the old logic
that uses _hashes before the commit, and consolidate link_hash back into
that attribute.
2023-01-04 18:42:52 +08:00
William Woodruff 464d16618e
src, tests: use deprecation instead of hard error for egg fragments
This turns invalid egg fragments into a soft error, with a scheduled
deprecation period of two releases.

Signed-off-by: William Woodruff <william@trailofbits.com>
2022-12-02 21:33:22 -08:00
William Woodruff 3c337a98cc
models/link: make egg fragment evaluation eager
This should prevent us from accepting malformed egg fragments
that are shadowed by other parts of the requirement specifier.

Signed-off-by: William Woodruff <william@trailofbits.com>
2022-11-22 17:26:40 -05:00
William Woodruff 4af0984cc3
models/link: reuse pyparsing + requirements combinators for egg fragment
This should now be consistent with existing tests (without establishing
that those tests are actually well-specified).

Signed-off-by: William Woodruff <william@trailofbits.com>
2022-11-22 15:50:45 -05:00
William Woodruff 98aa8b5298
Restrict `#egg=` fragments to valid PEP 508 names
This should help reduce user confusion about what can go in a URI's
egg fragment.

Fixes #11567.

Signed-off-by: William Woodruff <william@trailofbits.com>
2022-11-22 15:04:01 -05:00
Danny McClanahan bad03ef931
Use data-dist-info-metadata (PEP 658) to decouple resolution from downloading (#11111)
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2022-09-10 11:28:57 +01:00
Donald Stufft c1b46c19cf Document the hashes parameter 2022-07-15 17:43:17 -04:00
Donald Stufft 6f9ccfc136 Fix link hashes 2022-07-15 17:22:46 -04:00
Donald Stufft b64a067e53 Fix import ordering 2022-07-15 17:22:46 -04:00
Donald Stufft 5600eea70b Fix Typing on older Pythons 2022-07-15 17:22:46 -04:00
Donald Stufft 21fadc5858 fix typing 2022-07-15 17:22:46 -04:00
Donald Stufft 1fc571f3f6 Support Hashes from PEP691 2022-07-15 17:22:46 -04:00
Pradyun Gedam 94999255d5
Reformat the codebase, with black 2021-08-20 13:37:49 +01:00
Tzu-ping Chung 9b1bdf583b Move NameTuple method out of class
Suppport for defining methods on a typing.NameTuple was added in 3.6.1,
so this fixes compatibility to 3.6.0.
2021-08-07 10:26:06 +08:00
Tzu-ping Chung be89ea5d5b Correctly handle file://localhost/ and file:///
According to RFC 8089, an empty host value (i.e. "file:///") should be
taken to be "localhost" (i.e. "file://localhost/"), so we need to
perform some additional normalization to compare such URLs correctly.
2021-07-23 16:13:55 +08:00
Tzu-ping Chung 2da77e97a2 Smarter (and looser) link equivalency logic 2021-07-22 15:27:10 +08:00
Diego Ramirez 6958b87d3d
Complete type annotations: `pip/_internal/models` (#10138) 2021-07-12 11:43:52 +08:00
Jacob Walls 185120d725 Stop relying on undocumented duck typing by `urlunsplit()`
There are proposals in CPython to enforce correct types (str, bytes, bytearray) in urllib.parse: bpo-19094 and bpo-22234.
2021-06-13 11:33:18 -04:00
Max W Chase 4c69ab2a2c Support URL constraints in the new resolver
Fixes #8253
2021-04-17 07:59:57 -04:00
Pradyun Gedam c2ba7c043b
Merge pull request #9606 from hexagonrecursion/fstr 2021-02-21 08:30:00 +00: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
Andrey Bienkowski 9b2cb894ba Convert more str.format() calls to f-strings 2021-02-13 09:27:17 +03:00
Hugo van Kemenade a3e246f7d0 Cleanup: replace 'from urllib import xyz as urllib_xyz' with import urllib.xyz 2020-12-27 16:18:44 +02: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
Pradyun Gedam f91ba6b348
Merge pull request #9354 from jdufresne/super
Use short Python3 super() syntax
2020-12-25 19:18:28 +00:00
Jon Dufresne 5e11687cbd Replace typing.Text with str
Using typing.Text is unnecessary since dropping Python 2 support.

In Python 3, typing.Text is a simple alias of str. It exists as a
backward compatibility shim for Python 2.
2020-12-24 16:40:55 -08:00
Jon Dufresne c148bcc1aa Use short Python3 super() syntax 2020-12-24 15:11:51 -08:00
Hugo van Kemenade 817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
Pradyun Gedam 25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Cristina Muñoz ea3b0ab9a9 Add missing class attribute 2020-05-24 17:57:28 -07:00
Cristina Muñoz f6bf9a0065 Restrict dynamic attribute creation with slots
Fixes #7313.
2020-05-21 19:04:12 -07:00
Danny McClanahan 6e7b16cec4
add failing test ; apply the fix ; add template NEWS entry
add failing test

apply the fix

add template NEWS entry according to https://pip.pypa.io/en/latest/development/contributing/#news-entries (wrong PR #)

rename news entry to the current PR #

respond to review comments

fix test failures

fix tests by adding uuid salt in urls

cache html page fetching by link

make CI pass (?)

make the types much better

finally listen to the maintainer and cache parse_links() by url :)

avoid caching parse_links() when the url is an index url

cleanup

add testing for uncachable marking

only conditionally vendor _lru_cache for py2

bugfix => feature

python 2 does not cache!

Do away with type: ignore with getattr()

respond to review comments
2020-04-07 12:01:43 -07:00
Jason R. Coombs 6282a307dc 👹 Feed the hobgoblins (delint). 2020-03-06 12:43:10 -05:00
Jason R. Coombs 3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Anudit Nagar 082c0f01d2
Update old-style formatting to new-style formatting (#7762) 2020-02-21 21:48:14 +05:30
Deepak Sharma d31cf696e8 string_formatting 2020-01-30 20:33:00 +05:30
Maxim Kurnikov 3cb30385d8 remove disallow_untyped_defs=False for more modules 2019-12-13 10:22:21 +03:00
Chris Hunt 05b327ca2f Remove Optional from Link.show_url
Since we're moving functions to a file with stricter typing, this
prevents mypy from complaining that our string is possibly None.
2019-12-04 18:31:46 -05:00