Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix panic
  • Loading branch information
arihant2math committed Apr 18, 2025
commit 524eb9620f3f54722b9607db7b70fa75e3a96f05
23 changes: 20 additions & 3 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4231,6 +4231,8 @@ class MyChain(typing.ChainMap[str, T]): ...
self.assertIs(MyChain[int]().__class__, MyChain)
self.assertEqual(MyChain[int]().__orig_class__, MyChain[int])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_all_repr_eq_any(self):
objs = (getattr(typing, el) for el in typing.__all__)
for obj in objs:
Expand Down Expand Up @@ -5014,6 +5016,8 @@ def cached(self): ...


class OverrideDecoratorTests(BaseTestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_override(self):
class Base:
def normal_method(self): ...
Expand Down Expand Up @@ -5072,6 +5076,8 @@ def static_method_bad_order():
self.assertIs(False, hasattr(Base.static_method_good_order, "__override__"))
self.assertIs(False, hasattr(Base.static_method_bad_order, "__override__"))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_property(self):
class Base:
@property
Expand All @@ -5098,6 +5104,8 @@ def wrong(self) -> int:
self.assertFalse(hasattr(Child.wrong, "__override__"))
self.assertFalse(hasattr(Child.wrong.fset, "__override__"))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_silent_failure(self):
class CustomProp:
__slots__ = ('fget',)
Expand All @@ -5115,6 +5123,8 @@ def some(self):
self.assertEqual(WithOverride.some, 1)
self.assertFalse(hasattr(WithOverride.some, "__override__"))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_multiple_decorators(self):
def with_wraps(f): # similar to `lru_cache` definition
@wraps(f)
Expand Down Expand Up @@ -5948,9 +5958,10 @@ class WeirdlyQuotedMovie(TypedDict):
title: Annotated['Annotated[Required[str], "foobar"]', "another level"]
year: NotRequired['Annotated[int, 2000]']

class HasForeignBaseClass(mod_generics_cache.A):
some_xrepr: 'XRepr'
other_a: 'mod_generics_cache.A'
# TODO: RUSTPYTHON
# class HasForeignBaseClass(mod_generics_cache.A):
# some_xrepr: 'XRepr'
# other_a: 'mod_generics_cache.A'

async def g_with(am: typing.AsyncContextManager[int]):
x: int
Expand Down Expand Up @@ -6927,6 +6938,8 @@ def test_contextmanager_type_params(self):
type gen_cm[T1, T2] = typing.ContextManager[T1, T2]
self.assertEqual(get_args(gen_cm.__value__[int, None]), (int, types.NoneType))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_async_contextmanager(self):
class NotACM:
pass
Expand All @@ -6944,6 +6957,8 @@ def manager():
with self.assertRaises(TypeError):
typing.AsyncContextManager[int, str, float]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_asynccontextmanager_type_params(self):
cm1 = typing.AsyncContextManager[int]
self.assertEqual(get_args(cm1), (int, bool | None))
Expand Down Expand Up @@ -9814,6 +9829,8 @@ def test_all(self):
self.assertIn('SupportsBytes', a)
self.assertIn('SupportsComplex', a)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_all_exported_names(self):
# ensure all dynamically created objects are actualised
for name in typing.__all__:
Expand Down
28 changes: 15 additions & 13 deletions Lib/test/typinganndata/mod_generics_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@

from typing import TypeVar, Generic, Optional, TypeAliasType

default_a: Optional['A'] = None
default_b: Optional['B'] = None
# TODO: RUSTPYTHON

T = TypeVar('T')
# default_a: Optional['A'] = None
# default_b: Optional['B'] = None

# T = TypeVar('T')

class A(Generic[T]):
some_b: 'B'

# class A(Generic[T]):
# some_b: 'B'

class B(Generic[T]):
class A(Generic[T]):
pass

my_inner_a1: 'B.A'
my_inner_a2: A
my_outer_a: 'A' # unless somebody calls get_type_hints with localns=B.__dict__
# class B(Generic[T]):
# class A(Generic[T]):
# pass

type Alias = int
OldStyle = TypeAliasType("OldStyle", int)
# my_inner_a1: 'B.A'
# my_inner_a2: A
# my_outer_a: 'A' # unless somebody calls get_type_hints with localns=B.__dict__

# type Alias = int
# OldStyle = TypeAliasType("OldStyle", int)