Skip to content

Commit c831300

Browse files
committed
Upgrade typing_extensions to 4.14.1
1 parent eea4c4a commit c831300

File tree

3 files changed

+51
-45
lines changed

3 files changed

+51
-45
lines changed

news/typing_extensions.vendor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade typing_extensions to 4.14.0
1+
Upgrade typing_extensions to 4.14.1

src/pip/_vendor/typing_extensions.py

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,55 @@ def __new__(cls, *args, **kwargs):
221221

222222
ClassVar = typing.ClassVar
223223

224+
# Vendored from cpython typing._SpecialFrom
225+
# Having a separate class means that instances will not be rejected by
226+
# typing._type_check.
227+
class _SpecialForm(typing._Final, _root=True):
228+
__slots__ = ('_name', '__doc__', '_getitem')
229+
230+
def __init__(self, getitem):
231+
self._getitem = getitem
232+
self._name = getitem.__name__
233+
self.__doc__ = getitem.__doc__
234+
235+
def __getattr__(self, item):
236+
if item in {'__name__', '__qualname__'}:
237+
return self._name
238+
239+
raise AttributeError(item)
240+
241+
def __mro_entries__(self, bases):
242+
raise TypeError(f"Cannot subclass {self!r}")
243+
244+
def __repr__(self):
245+
return f'typing_extensions.{self._name}'
246+
247+
def __reduce__(self):
248+
return self._name
249+
250+
def __call__(self, *args, **kwds):
251+
raise TypeError(f"Cannot instantiate {self!r}")
252+
253+
def __or__(self, other):
254+
return typing.Union[self, other]
255+
256+
def __ror__(self, other):
257+
return typing.Union[other, self]
258+
259+
def __instancecheck__(self, obj):
260+
raise TypeError(f"{self} cannot be used with isinstance()")
261+
262+
def __subclasscheck__(self, cls):
263+
raise TypeError(f"{self} cannot be used with issubclass()")
264+
265+
@typing._tp_cache
266+
def __getitem__(self, parameters):
267+
return self._getitem(self, parameters)
268+
224269

270+
# Note that inheriting from this class means that the object will be
271+
# rejected by typing._type_check, so do not use it if the special form
272+
# is arguably valid as a type by itself.
225273
class _ExtensionsSpecialForm(typing._SpecialForm, _root=True):
226274
def __repr__(self):
227275
return 'typing_extensions.' + self._name
@@ -1223,7 +1271,7 @@ def _create_typeddict(
12231271
td.__orig_bases__ = (TypedDict,)
12241272
return td
12251273

1226-
class _TypedDictSpecialForm(_ExtensionsSpecialForm, _root=True):
1274+
class _TypedDictSpecialForm(_SpecialForm, _root=True):
12271275
def __call__(
12281276
self,
12291277
typename,
@@ -2201,48 +2249,6 @@ def cast[T](typ: TypeForm[T], value: Any) -> T: ...
22012249
return typing._GenericAlias(self, (item,))
22022250

22032251

2204-
# Vendored from cpython typing._SpecialFrom
2205-
class _SpecialForm(typing._Final, _root=True):
2206-
__slots__ = ('_name', '__doc__', '_getitem')
2207-
2208-
def __init__(self, getitem):
2209-
self._getitem = getitem
2210-
self._name = getitem.__name__
2211-
self.__doc__ = getitem.__doc__
2212-
2213-
def __getattr__(self, item):
2214-
if item in {'__name__', '__qualname__'}:
2215-
return self._name
2216-
2217-
raise AttributeError(item)
2218-
2219-
def __mro_entries__(self, bases):
2220-
raise TypeError(f"Cannot subclass {self!r}")
2221-
2222-
def __repr__(self):
2223-
return f'typing_extensions.{self._name}'
2224-
2225-
def __reduce__(self):
2226-
return self._name
2227-
2228-
def __call__(self, *args, **kwds):
2229-
raise TypeError(f"Cannot instantiate {self!r}")
2230-
2231-
def __or__(self, other):
2232-
return typing.Union[self, other]
2233-
2234-
def __ror__(self, other):
2235-
return typing.Union[other, self]
2236-
2237-
def __instancecheck__(self, obj):
2238-
raise TypeError(f"{self} cannot be used with isinstance()")
2239-
2240-
def __subclasscheck__(self, cls):
2241-
raise TypeError(f"{self} cannot be used with issubclass()")
2242-
2243-
@typing._tp_cache
2244-
def __getitem__(self, parameters):
2245-
return self._getitem(self, parameters)
22462252

22472253

22482254
if hasattr(typing, "LiteralString"): # 3.11+

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requests==2.32.4
1111
urllib3==1.26.20
1212
rich==14.0.0
1313
pygments==2.19.2
14-
typing_extensions==4.14.0
14+
typing_extensions==4.14.1
1515
resolvelib==1.2.0
1616
setuptools==70.3.0
1717
tomli==2.2.1

0 commit comments

Comments
 (0)