Commit Graph

58 Commits

Author SHA1 Message Date
Damian Shaw 68529081c2
Enforce f-strings via Ruff (#12393) 2023-11-07 09:14:56 +00:00
Shantanu 901db9cf8d
Use a set for TargetPython.get_tags for performance (#12204) 2023-08-06 11:08:16 -05:00
Tzu-ping Chung dc8ac7b896 Enable strict optional checking in PackageFinder
Most should be pretty straightforward. In one place I need to use a
custom TypeGuard, available in typing_extensions, which we're vendoring
for Rich.
2023-01-09 17:27:40 +08:00
Stéphane Bidoul bb2a3d7410
Remove the html5lib deprecated feature flag. 2022-07-16 19:37:11 +02:00
Donald Stufft 6f167b55a9 PoC of PEP 691 2022-07-15 17:22:46 -04:00
Tzu-ping Chung d61b539353 More structured link evaluation result
A new enum class is implemented for the link evaluator to use instead
of a simple boolean to better distinguish between various evaluation
errors. This allows the caller to better distinguish error sources with
a structured check instead of fragile error string comparison.
2022-03-10 20:41:26 +08:00
Tzu-ping Chung 60fe6c0cb8
Use new-style variable type annotation 2022-03-10 15:44:12 +08:00
Tzu-ping Chung 2e5e9e54bc
Merge branch 'main' into requires-python 2022-03-10 15:41:05 +08:00
Jon Dufresne bf5f4008e7
Replace vendored html5lib with stdlib
The html5lib library isn't strictly required as the same functionality
can be achieved through the stdlib html.parser module.

The html5lib is one of the largest uses of the six library. By dropping
this unnecessary dependency, the pip project is closer to dropping the
six library.

Additionally, html5lib maintenance has slowed down and the project has
rejected pull requests to drop Python 2 support.

For now, the html5lib code remains, but is gated behind a command
line option: `--use-deprecated=html5lib`. After a sufficient amount of
time has passed without any reported bugs, the vendored library and this
flag can be removed completely.
2022-01-28 06:45:57 +00:00
Pradyun Gedam 4cdf146f5d
Fix crashes with higher verbosity levels
This was causing issues in running the test suite locally at higher
verbosity levels, since this block causes errors when passed a URL.
2021-12-04 19:01:58 +00:00
Tzu-ping Chung c54d40474a CHange ireq.satisfied_by to abstract distribution 2021-11-18 17:58:10 +08:00
ronaudinho 22ea509025
update log message 2021-09-21 00:33:02 +07:00
ronaudinho 48fa931fa3 simplify skipped links deduplication 2021-09-19 12:58:11 +07:00
ronaudinho f2727bcf11 include skips due to requires-python in logged links 2021-09-19 12:55:29 +07:00
ronaudinho eea594265f lint 2021-09-19 12:54:13 +07:00
ronaudinho 42613daf36 explain requires-python ignored links 2021-09-19 12:54:12 +07:00
Pradyun Gedam 585037a80a
Cleanup implicit string concatenation 2021-08-20 13:37:52 +01:00
Pradyun Gedam 1897784d59
Blacken src/pip/_internal/index 2021-08-06 13:41:13 +01:00
harupy 6ff78f0b59 Convert type comments 2021-07-23 23:51:54 +09:00
Diego Ramirez ce86dc86d6
Complete type annotations in `pip/_internal/index` (#10111) 2021-07-13 03:28:36 +08:00
Tzu-ping Chung 62f481679a Move "Link requires a different Python" to verbose 2021-06-20 05:21:11 +08:00
Tzu-ping Chung a912c5530d Rewrite collect_links
This introduces a collect_sources() method to do the same thing, but
instead of flattening links eagerly, return each repository entry
separately (and return a None for invalid repository options), so
subsequent code can better distinguish which link comes from which
repository.
2021-04-13 03:16:36 +08:00
Joseph Bylund d2c280be64
Improve Performance of Picking Best Candidate from Indexes
Use a mapping for random lookup instead of list traversal.
2021-04-03 23:25:36 +08:00
Andrey Bienkowski e96791f106 Lint 2021-04-02 15:17:59 +03:00
Andrey Bienkowski 426279c39a Sort order: compatibility tags are more important than build tag 2021-04-02 15:01:04 +03: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
Jim Fisher a1d41f3fe2 split line to please linter 2021-02-19 10:55:56 +00:00
Jim Fisher 2ca21dfc12
Point user to `pip debug --verbose` to debug incompatible wheel
Resolves https://github.com/pypa/pip/issues/9621
2021-02-19 10:33:56 +00: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
Pradyun Gedam 86afa89043
Merge pull request #9361 from jdufresne/f-strings
Use f-strings for simple string formatting
2020-12-26 10:24:18 +00:00
Pradyun Gedam 31eb524ff0
Merge pull request #9351 from jdufresne/object
Remove object from class definitions
2020-12-26 10:21:40 +00:00
Pradyun Gedam 4e48ba838b
Merge pull request #9356 from jdufresne/lru-cache
Replace utils.compat.lru_cache with stdlib functools.lru_cache
2020-12-26 09:20:20 +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 09b3d3a50b Remove object from class definitions
Unnecessary since dropping Python 2 support. In Python 3, all classes
are new style classes.
2020-12-25 15:48:11 -08:00
Jon Dufresne 17d72b748f Replace utils.compat.lru_cache with stdlib functools.lru_cache
The stdlib version has been available since Python 3.2.
2020-12-25 08:51:15 -08:00
Jon Dufresne 2e38024991 Drop u prefix from str literals
Unnecessary since dropping Python 2 support.

This makes one test case from test_str_to_display a duplicate and so has
been removed.
2020-12-25 07:26:06 -08: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 f32adaf09b Remove __future__ imports
Unnecessary since dropping Python 2.
2020-12-24 08:38:09 -08:00
Xavier Fernandez 5ec275fca2 Cache find_best_candidate results
This is possible because self.make_candidate_evaluator only depends
on:
- the function arguments which are keys to the cache
- self._target_python which never changes during a pip resolution
- self._candidate_prefs which never changes during a pip resolution

On a fresh install, pip install <a package with ~ 100 dependencies>
runs on my machine in:

master (a0e34e9cf7)
=======================

0m33.058s
0m34.105s
0m32.426s

This commit
===========

0m15.860s
0m16.254s
0m15.910s

pip 20.2.4 - legacy resolver
============================

0m15.145s
0m15.040s
0m15.152s
2020-10-31 16:22:59 +01:00
Tzu-ping Chung 1dd6d56278 Cache PackageFinder.find_all_candidates() 2020-09-26 15:26:05 +08:00
Pradyun Gedam 58c594c06b
Prepare isort for black 2020-09-23 21:47:47 +05:30
Pradyun Gedam 25ab172b55
Update linter: isort 2020-09-23 19:52:28 +05:30
Tzu-ping Chung ebb90c6411 Reject incompatibile direct wheel link
This mirrors the behavior in the legacy resolver. In the future we may
want to backtrack in this situation instead, but I haven't found a clean
way to do this. We may need to introduce an "empty" requirement class.

The `PackageFinder.target_python` interface is also not the most clean.
Maybe we should expose the target Python object instead. Not sure yet.
2020-06-10 20:57:23 +08:00
Devesh Kumar Singh 0d48186d1b Allow --prefer-binary option in requirements file 2020-05-21 19:37:45 +05:30
Tzu-ping Chung 806067f09f Move yanked link warning into the legacy resolver 2020-04-25 02:28:43 +08:00
Tzu-ping Chung f35f37ef72 Add find_requirement() wrapper in legacy resolver 2020-04-25 02:28:43 +08:00
Deepak Sharma d31cf696e8 string_formatting 2020-01-30 20:33:00 +05:30
Chris Hunt 80b2c82d0c Use packaging.tags.Tag in place of Tuple
This is the standard type used by packaging.tags. Making this change
throughout the code lets us start switching over to using its
tag-generating functions in get_supported().

We also get rid of a test, since it was superseded by `__str__` in
packaging.tags.Tag.
2020-01-07 01:42:42 -05:00
Maxim Kurnikov 3cb30385d8 remove disallow_untyped_defs=False for more modules 2019-12-13 10:22:21 +03:00
Chris Hunt 60f6ed9387 Move wheel.Wheel to models.wheel.Wheel
This aligns more closely with how the class is used and makes it easier
to move the rest of the wheel module to a dedicated module for
installation.
2019-12-02 11:52:51 +08:00