1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00
Commit graph

64 commits

Author SHA1 Message Date
Stéphane Bidoul
6e5d467822 Various fixes to the link hash parser 2023-04-07 23:07:01 +02:00
Pradyun Gedam
78ab4cf071
Bump all linters other than mypy (#11901) 2023-03-27 20:03:11 +01: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
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
Stéphane Bidoul
bb2a3d7410
Remove the html5lib deprecated feature flag. 2022-07-16 19:37:11 +02:00
Donald Stufft
c1b50e1f4d Add a test for parsing links from JSON 2022-07-15 17:55:15 -04:00
Donald Stufft
68836d479f fix number of calls 2022-07-15 17:22:46 -04:00
Donald Stufft
7cb5aae880 fix a stray ' 2022-07-15 17:22:46 -04:00
Donald Stufft
6f9ccfc136 Fix link hashes 2022-07-15 17:22:46 -04:00
Donald Stufft
d67cac3c13 formatting 2022-07-15 17:22:46 -04:00
Donald Stufft
799c88f13d Update some tests to work again 2022-07-15 17:22:46 -04:00
Donald Stufft
9c98346df9 Add new accept headers 2022-07-15 17:22:46 -04:00
Donald Stufft
21a99e4b87 Update tests to use new names 2022-07-15 17:22:46 -04:00
Donald Stufft
55192a1674 Fix tests 2022-07-15 17:22:46 -04:00
Tzu-ping Chung
42359a9605 Migrate tests to use pathlib.Path
The pip-specific Path implementation has been removed, and all its
usages replaced by pathlib.Path. The tmpdir and tmpdir_factory fixtures
are also removed, and all usages are replaced by tmp_path and
tmp_path_factory, which use pathlib.Path.

The pip() function now also accepts pathlib.Path so we don't need to put
str() everywhere. Path arguments are coerced with os.fspath() into str.
2022-06-08 19:58:46 +08:00
q0w
a4f7508592
Drop the doctype check (#10906)
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
2022-02-27 12:39:06 +00:00
Pradyun Gedam
4f0ce011fe
Switch to using html.parser even when the doctype isn't proper
This ensures that we handle html5lib parsing as non-default deprecated
behaviour.
2022-02-01 17:58:34 +00:00
Pradyun Gedam
c01b0b2729
Gracefully fallback to html5lib for parsing non-compliant index pages
This reworks the HTML parsing logic, to gracefully use `html5lib` on
non-compliant HTML 5 documents. This warning softens the failure mode
for users who are using commercial package index solutions that do not
follow the requisite standards and serve malformed HTML documents.
2022-01-30 21:21:11 +00:00
Pradyun Gedam
80609e8c20
Properly yield results from html5lib parsing
The earlier variant _returned_ an iterable object from a generator. This
did not properly handle the fallback, resulting in the html5lib code
path not being executed.
2022-01-30 16:54:45 +00: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
Jon Dufresne
60c274be2d Complete type annotations of tests/unit/ directory 2021-09-23 05:44:54 -07:00
Tzu-ping Chung
b9fcd554a2
Merge pull request #10378 from jdufresne/unescape
Remove unnecessary html.unescape() calls in index/collector.py
2021-09-05 17:49:59 +08:00
Jon Dufresne
4a4103e173 Replace use of pretend library with unitest.mock in tests
The pretend library was used by very few tests. In all cases, it is
simple enough to switch to stdlib unitest.mock.

Using stdlib means there is one fewer library to install before running
tests. It can also simplify mypy usage via typeshed.
2021-09-03 16:23:28 -07:00
Jon Dufresne
af3405738b Remove unnecessary html.unescape() calls in index/collector.py
The html5lib package (as well as stdlib html.parser) already unescapes
attributes. There is no need to do so a second time.

Unnecessary since cba45215b9.
2021-08-20 10:25:32 -06:00
Pradyun Gedam
585037a80a
Cleanup implicit string concatenation 2021-08-20 13:37:52 +01:00
Pradyun Gedam
94999255d5
Reformat the codebase, with black 2021-08-20 13:37:49 +01: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
Pradyun Gedam
c2ba7c043b
Merge pull request #9606 from hexagonrecursion/fstr 2021-02-21 08:30:00 +00:00
Andrey Bienkowski
9b2cb894ba Convert more str.format() calls to f-strings 2021-02-13 09:27:17 +03:00
Andrey Bienkowski
50db373adb Lint 2021-02-10 13:38:21 +03:00
Andrey Bienkowski
ab35018c04 Use unittest.mock instead of mock 2021-02-10 13:28:55 +03:00
Jon Dufresne
5150129f6b Replace compat.expanduser() with os.path.expanduser()
The upstream bug has been fixed and released in all supported Python
version: https://bugs.python.org/issue14768
2020-12-29 08:15:55 -08: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
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
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
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
Hugo van Kemenade
817ee23051 Remove redundant Python 2.7 code 2020-12-22 09:06:26 +02:00
gutsytechster
8c267e6e39
feat(pip/_internal/*): Use custom raise_for_status method 2020-07-08 18:08:55 +05:30
Christopher Hunt
4ba51d2e9c
Merge pull request #8501 from uranusjr/refactor-create-link-collector
Tidy up link collector constructor imports
2020-07-05 21:44:31 -04:00
Devesh Kumar Singh
6c899ed0c8 Update warning message to specify HTTP request 2020-06-29 22:20:11 +05:30
Devesh Kumar Singh
46790a4f3c Improve warning message for invalid vcs schemes 2020-06-28 16:23:07 +05:30
Devesh Kumar Singh
499e112275 Add unit tests to check vcs and archive url with invalid scheme 2020-06-28 16:23:07 +05:30
Tzu-ping Chung
ec7324fba0 Tidy up link collector constructor imports
make_link_collector() was in self_outdated_check, a module responsible
for checking whether the currently-running pip is outdated, but is
imported by things that has nothing to do with this outdated check. Move
the function to be a class method in LinkCollector so the module
hierarchy makes more sense.
2020-06-26 17:31:28 +08:00
Devesh Kumar Singh
64c78b19b9 Reword warning for invalid content-type 2020-05-21 19:37:03 +05:30
Devesh Kumar Singh
fa67244d45 Add unit test to warn on invalid content-type 2020-05-21 19:37:03 +05:30
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
3511d3d493 Convert the remaining '%' formatters to '.format'. Fixes #6973. 2020-03-06 12:43:03 -05:00
Tzu-ping Chung
cdd7821d92 Fix incorrect quoting Link.url
Cherry-picked manually from atugushev:fix-issue-6446.

Co-Authored-By: Albert Tugushev <albert@tugushev.ru>
2020-01-14 16:12:11 +08:00
Chris Jerdonek
bab1e4f8a1 Change CollectedLinks to store project_urls. 2019-11-10 21:27:00 -05:00