forked from python/typing_extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
- Pickling of
typing_extensions.AsyncContextManager[Any]andtyping_extensions.ContextManager[Any]goes through_GenericAliaswhose__reduce__is
def __reduce__(self):
if self._name:
origin = globals()[self._name]
else:
origin = self.__origin__
args = tuple(self.__args__)
if len(args) == 1 and not isinstance(args[0], tuple):
args, = args
return operator.getitem, (origin, args)
and grabs typing.AsyncContextManager instead of typing_extensions.AsyncContextManager. Not sure how to solve
- There are explicit checks AGAINST what we are backporting in 3.12 for AsyncContextManager:
- Added a sed to fix it
self.assertEqual(typing.AsyncContextManager[int].__args__, (int,))
with self.assertRaises(TypeError):
isinstance(42, typing.AsyncContextManager[int])
with self.assertRaises(TypeError):
typing.AsyncContextManager[int, str]
- ParamSpec (and others)
__module__gets set to__main__instead ofNoneon exec:
def test_basic_with_exec(self):
ns = {}
exec('from typing_extensions import ParamSpec; P = ParamSpec("P")', ns, ns)
P = ns['P']
self.assertIsInstance(P, ParamSpec)
self.assertEqual(P.__name__, 'P')
self.assertIs(P.__module__, None)
And in typing extensions we have:
class ParamSpec(metaclass=_TypeVarLikeMeta):
def __new__(cls, name, *, bound=None,
covariant=False, contravariant=False,
infer_variance=False, default=NoDefault):
...
_set_module(paramspec)
def _set_module(typevarlike):
# for pickling:
def_mod = _caller(depth=2)
if def_mod != 'typing_extensions':
typevarlike.__module__ = def_mod
def _caller(depth=1, default='__main__'):
try:
return sys._getframemodulename(depth + 1) or default
except AttributeError: # For platforms without _getframemodulename()
pass
try:
return sys._getframe(depth + 1).f_globals.get('__name__', default)
except (AttributeError, ValueError): # For platforms without _getframe()
pass
return None
-
Segfault in 3.14 and 3.13
- Comes from: https://github.com/python/cpython/blob/3.14/Lib/test/test_typing.py#L5800
- gh-138479: Ensure that
__typing_subst__returns a tuple python/cpython#138482 - Test is in the branch, but uv/CI grabs the release which doesnt have the fix yet
-
dataclass in 3.11
- Test has an exact match requirement and reference is missing the argument added in 3.12
- Can be sed'ed
FAIL: test_base_class (__main__.DataclassTransformTests.test_base_class)
----------------------------------------------------------------------
Traceback (most recent call last):
File "<stdin>", line 8583, in test_base_class
AssertionError: {'eq_[62 chars]e, 'frozen_default': False, 'field_specifiers'[45 chars]rue}} != {'eq_[62 chars]e, 'field_specifiers': (), 'kwargs': {'make_ev[20 chars]rue}}
{'eq_default': True,
'field_specifiers': (),
- 'frozen_default': False,
'kw_only_default': False,
'kwargs': {'make_everything_awesome': True},
'order_default': True}
- Overload registry:
- Testing typing internals, dont think its worth to debug. Can be skipped with a sed.
======================================================================
FAIL: test_overload_registry (__main__.OverloadTests.test_overload_registry)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.13/x64/lib/python3.11/unittest/mock.py", line 1378, in patched
return func(*newargs, **newkeywargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<stdin>", line 5256, in test_overload_registry
AssertionError: defaultdict(<function OverloadTests.<lambda> at 0x7f6150560860>, {}) == {}
-
TypeVarTupleTests.test_bad_var_substitution: no error raised
- The issue is that
TypeVar__typing_subst__has this checkif ((isinstance(arg, typing._GenericAlias) and arg.__origin__ is typing.Unpack) - Can be fixed with a monkey patch
- The issue is that
-
Unpack repr syntax
- Changed because of using in hinting kwargs.
-
3.10/3.9 Any tests
- Any used to not be subclassable or useable in
issubclass. - This has changed and we are backporting this ability.
- Tests can be skipped with sed
- Any used to not be subclassable or useable in
-
ConcatenateTests
- Change in CPython from 3.10 -> 3.11 to allow "C = Concatenate[T, P]; C[int, ...]"
- Change to allow ellipsis in second position, we are backporting that. So test needs to be fixed
-
3.10/3.9 Implicit Option
right: 'Node[T]' = None,- See note about changes in 3.11 here: https://docs.python.org/3/library/typing.html#typing.get_type_hints
-
Pickling and printing errors
Metadata
Metadata
Assignees
Labels
No labels