Skip to content

Commit e8e592a

Browse files
authored
Merge pull request #12670 from pradyunsg/vendoring-upgrade
Upgrade various vendored dependencies
2 parents bc84491 + d24ddc3 commit e8e592a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3631
-1344
lines changed

news/CacheControl.vendor.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade CacheControl to 0.14.0

news/idna.vendor.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade idna to 3.6
1+
Upgrade idna to 3.7

news/platformdirs.vendor.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade platformdirs to 4.2.0
1+
Upgrade platformdirs to 4.2.1

news/pyparsing.vendor.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade pyparsing to 3.1.2

news/rich.vendor.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade rich to 13.7.0
1+
Upgrade rich to 13.7.1

news/setuptools.vendor.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade setuptools to 69.1.1
1+
Upgrade setuptools to 69.5.1

news/typing_extensions.vendor.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade typing_extensions to 4.9.0
1+
Upgrade typing_extensions to 4.11.0

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ distro = []
144144
setuptools = "pkg_resources"
145145

146146
[tool.vendoring.license.fallback-urls]
147-
CacheControl = "https://raw.githubusercontent.com/ionrock/cachecontrol/v0.12.6/LICENSE.txt"
148147
distlib = "https://bitbucket.org/pypa/distlib/raw/master/LICENSE.txt"
149148
webencodings = "https://github.com/SimonSapin/python-webencodings/raw/master/LICENSE"
150149

src/pip/_vendor/cachecontrol/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99
__author__ = "Eric Larson"
1010
__email__ = "[email protected]"
11-
__version__ = "0.13.1"
11+
__version__ = "0.14.0"
1212

1313
from pip._vendor.cachecontrol.adapter import CacheControlAdapter
1414
from pip._vendor.cachecontrol.controller import CacheController

src/pip/_vendor/cachecontrol/adapter.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ def build_response(
125125
else:
126126
# Wrap the response file with a wrapper that will cache the
127127
# response when the stream has been consumed.
128-
response._fp = CallbackFileWrapper( # type: ignore[attr-defined]
129-
response._fp, # type: ignore[attr-defined]
128+
response._fp = CallbackFileWrapper( # type: ignore[assignment]
129+
response._fp, # type: ignore[arg-type]
130130
functools.partial(
131131
self.controller.cache_response, request, response
132132
),
133133
)
134134
if response.chunked:
135-
super_update_chunk_length = response._update_chunk_length # type: ignore[attr-defined]
135+
super_update_chunk_length = response._update_chunk_length
136136

137137
def _update_chunk_length(self: HTTPResponse) -> None:
138138
super_update_chunk_length()
139139
if self.chunk_left == 0:
140-
self._fp._close() # type: ignore[attr-defined]
140+
self._fp._close() # type: ignore[union-attr]
141141

142-
response._update_chunk_length = types.MethodType( # type: ignore[attr-defined]
142+
response._update_chunk_length = types.MethodType( # type: ignore[method-assign]
143143
_update_chunk_length, response
144144
)
145145

src/pip/_vendor/cachecontrol/caches/file_cache.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import hashlib
77
import os
88
from textwrap import dedent
9-
from typing import IO, TYPE_CHECKING
9+
from typing import IO, TYPE_CHECKING, Union
10+
from pathlib import Path
1011

1112
from pip._vendor.cachecontrol.cache import BaseCache, SeparateBodyBaseCache
1213
from pip._vendor.cachecontrol.controller import CacheController
@@ -63,7 +64,7 @@ class _FileCacheMixin:
6364

6465
def __init__(
6566
self,
66-
directory: str,
67+
directory: str | Path,
6768
forever: bool = False,
6869
filemode: int = 0o0600,
6970
dirmode: int = 0o0700,
@@ -79,7 +80,7 @@ def __init__(
7980
"""
8081
NOTE: In order to use the FileCache you must have
8182
filelock installed. You can install it via pip:
82-
pip install filelock
83+
pip install cachecontrol[filecache]
8384
"""
8485
)
8586
raise ImportError(notice)

src/pip/_vendor/cachecontrol/controller.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ def _load_from_cache(self, request: PreparedRequest) -> HTTPResponse | None:
142142
"""
143143
Load a cached response, or return None if it's not available.
144144
"""
145+
# We do not support caching of partial content: so if the request contains a
146+
# Range header then we don't want to load anything from the cache.
147+
if "Range" in request.headers:
148+
return None
149+
145150
cache_url = request.url
146151
assert cache_url is not None
147152
cache_data = self.cache.get(cache_url)
@@ -480,7 +485,7 @@ def update_cached_response(
480485
cached_response.headers.update(
481486
{
482487
k: v
483-
for k, v in response.headers.items() # type: ignore[no-untyped-call]
488+
for k, v in response.headers.items()
484489
if k.lower() not in excluded_headers
485490
}
486491
)

src/pip/_vendor/cachecontrol/heuristics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def update_headers(self, response: HTTPResponse) -> dict[str, str]:
6868

6969
if "expires" not in response.headers:
7070
date = parsedate(response.headers["date"])
71-
expires = expire_after(timedelta(days=1), date=datetime(*date[:6], tzinfo=timezone.utc)) # type: ignore[misc]
71+
expires = expire_after(timedelta(days=1), date=datetime(*date[:6], tzinfo=timezone.utc)) # type: ignore[index,misc]
7272
headers["expires"] = datetime_to_header(expires)
7373
headers["cache-control"] = "public"
7474
return headers

src/pip/_vendor/cachecontrol/serialize.py

+8-68
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ def dumps(
3232
# also update the response with a new file handler to be
3333
# sure it acts as though it was never read.
3434
body = response.read(decode_content=False)
35-
response._fp = io.BytesIO(body) # type: ignore[attr-defined]
35+
response._fp = io.BytesIO(body) # type: ignore[assignment]
3636
response.length_remaining = len(body)
3737

3838
data = {
3939
"response": {
4040
"body": body, # Empty bytestring if body is stored separately
41-
"headers": {str(k): str(v) for k, v in response.headers.items()}, # type: ignore[no-untyped-call]
41+
"headers": {str(k): str(v) for k, v in response.headers.items()},
4242
"status": response.status,
4343
"version": response.version,
4444
"reason": str(response.reason),
@@ -72,31 +72,14 @@ def loads(
7272
if not data:
7373
return None
7474

75-
# Determine what version of the serializer the data was serialized
76-
# with
77-
try:
78-
ver, data = data.split(b",", 1)
79-
except ValueError:
80-
ver = b"cc=0"
81-
82-
# Make sure that our "ver" is actually a version and isn't a false
83-
# positive from a , being in the data stream.
84-
if ver[:3] != b"cc=":
85-
data = ver + data
86-
ver = b"cc=0"
87-
88-
# Get the version number out of the cc=N
89-
verstr = ver.split(b"=", 1)[-1].decode("ascii")
90-
91-
# Dispatch to the actual load method for the given version
92-
try:
93-
return getattr(self, f"_loads_v{verstr}")(request, data, body_file) # type: ignore[no-any-return]
94-
95-
except AttributeError:
96-
# This is a version we don't have a loads function for, so we'll
97-
# just treat it as a miss and return None
75+
# Previous versions of this library supported other serialization
76+
# formats, but these have all been removed.
77+
if not data.startswith(f"cc={self.serde_version},".encode()):
9878
return None
9979

80+
data = data[5:]
81+
return self._loads_v4(request, data, body_file)
82+
10083
def prepare_response(
10184
self,
10285
request: PreparedRequest,
@@ -149,49 +132,6 @@ def prepare_response(
149132

150133
return HTTPResponse(body=body, preload_content=False, **cached["response"])
151134

152-
def _loads_v0(
153-
self,
154-
request: PreparedRequest,
155-
data: bytes,
156-
body_file: IO[bytes] | None = None,
157-
) -> None:
158-
# The original legacy cache data. This doesn't contain enough
159-
# information to construct everything we need, so we'll treat this as
160-
# a miss.
161-
return None
162-
163-
def _loads_v1(
164-
self,
165-
request: PreparedRequest,
166-
data: bytes,
167-
body_file: IO[bytes] | None = None,
168-
) -> HTTPResponse | None:
169-
# The "v1" pickled cache format. This is no longer supported
170-
# for security reasons, so we treat it as a miss.
171-
return None
172-
173-
def _loads_v2(
174-
self,
175-
request: PreparedRequest,
176-
data: bytes,
177-
body_file: IO[bytes] | None = None,
178-
) -> HTTPResponse | None:
179-
# The "v2" compressed base64 cache format.
180-
# This has been removed due to age and poor size/performance
181-
# characteristics, so we treat it as a miss.
182-
return None
183-
184-
def _loads_v3(
185-
self,
186-
request: PreparedRequest,
187-
data: bytes,
188-
body_file: IO[bytes] | None = None,
189-
) -> None:
190-
# Due to Python 2 encoding issues, it's impossible to know for sure
191-
# exactly how to load v3 entries, thus we'll treat these as a miss so
192-
# that they get rewritten out as v4 entries.
193-
return None
194-
195135
def _loads_v4(
196136
self,
197137
request: PreparedRequest,

src/pip/_vendor/idna/LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2013-2023, Kim Davies and contributors.
3+
Copyright (c) 2013-2024, Kim Davies and contributors.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

src/pip/_vendor/idna/core.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ def valid_contextj(label: str, pos: int) -> bool:
150150
joining_type = idnadata.joining_types.get(ord(label[i]))
151151
if joining_type == ord('T'):
152152
continue
153-
if joining_type in [ord('L'), ord('D')]:
153+
elif joining_type in [ord('L'), ord('D')]:
154154
ok = True
155155
break
156+
else:
157+
break
156158

157159
if not ok:
158160
return False
@@ -162,9 +164,11 @@ def valid_contextj(label: str, pos: int) -> bool:
162164
joining_type = idnadata.joining_types.get(ord(label[i]))
163165
if joining_type == ord('T'):
164166
continue
165-
if joining_type in [ord('R'), ord('D')]:
167+
elif joining_type in [ord('R'), ord('D')]:
166168
ok = True
167169
break
170+
else:
171+
break
168172
return ok
169173

170174
if cp_value == 0x200d:
@@ -236,12 +240,8 @@ def check_label(label: Union[str, bytes, bytearray]) -> None:
236240
if intranges_contain(cp_value, idnadata.codepoint_classes['PVALID']):
237241
continue
238242
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTJ']):
239-
try:
240-
if not valid_contextj(label, pos):
241-
raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format(
242-
_unot(cp_value), pos+1, repr(label)))
243-
except ValueError:
244-
raise IDNAError('Unknown codepoint adjacent to joiner {} at position {} in {}'.format(
243+
if not valid_contextj(label, pos):
244+
raise InvalidCodepointContext('Joiner {} not allowed at position {} in {}'.format(
245245
_unot(cp_value), pos+1, repr(label)))
246246
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTO']):
247247
if not valid_contexto(label, pos):
@@ -262,13 +262,8 @@ def alabel(label: str) -> bytes:
262262
except UnicodeEncodeError:
263263
pass
264264

265-
if not label:
266-
raise IDNAError('No Input')
267-
268-
label = str(label)
269265
check_label(label)
270-
label_bytes = _punycode(label)
271-
label_bytes = _alabel_prefix + label_bytes
266+
label_bytes = _alabel_prefix + _punycode(label)
272267

273268
if not valid_label_length(label_bytes):
274269
raise IDNAError('Label too long')

0 commit comments

Comments
 (0)