Visitar URL original
Fix genericalias parameters by youknowone · Pull Request #5841 · RustPython/RustPython · GitHub
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 attr_exceptions list
  • Loading branch information
youknowone committed Jun 26, 2025
commit 433f24e60d80d61fbf58d788fd184b9f20733760
29 changes: 0 additions & 29 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2220,8 +2220,6 @@ class B(metaclass=UnhashableMeta): ...
with self.assertRaises(TypeError):
hash(union3)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(Union), 'typing.Union')
u = Union[Employee, int]
Expand Down Expand Up @@ -2389,8 +2387,6 @@ def test_tuple_instance_type_error(self):
isinstance((0, 0), Tuple[int, int])
self.assertIsInstance((0, 0), Tuple)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(Tuple), 'typing.Tuple')
self.assertEqual(repr(Tuple[()]), 'typing.Tuple[()]')
Expand Down Expand Up @@ -2472,8 +2468,6 @@ def f():
with self.assertRaises(TypeError):
isinstance(None, Callable[[], Any])

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
Callable = self.Callable
fullname = f'{Callable.__module__}.Callable'
Expand Down Expand Up @@ -2717,11 +2711,6 @@ def test_errors(self):
class TypingCallableTests(BaseCallableTests, BaseTestCase):
Callable = typing.Callable

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_var_substitution(self):
super().test_var_substitution()

def test_consistency(self):
# bpo-42195
# Testing collections.abc.Callable's consistency with typing.Callable
Expand Down Expand Up @@ -3554,8 +3543,6 @@ def __init__(self, x: T) -> None:

class GenericTests(BaseTestCase):

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_basics(self):
X = SimpleMapping[str, Any]
self.assertEqual(X.__parameters__, ())
Expand Down Expand Up @@ -3602,8 +3589,6 @@ class D(Generic[T]): pass
with self.assertRaises(TypeError):
D[()]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_generic_subclass_checks(self):
for typ in [list[int], List[int],
tuple[int, str], Tuple[int, str],
Expand Down Expand Up @@ -4515,8 +4500,6 @@ class A(typing.Sized, list[int]): ...
(A, collections.abc.Sized, Generic, list, object),
)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_multiple_inheritance_with_genericalias_2(self):
T = TypeVar("T")

Expand Down Expand Up @@ -4840,8 +4823,6 @@ def test_basics(self):
with self.assertRaises(TypeError):
Optional[Final[int]]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(Final), 'typing.Final')
cv = Final[int]
Expand Down Expand Up @@ -6500,8 +6481,6 @@ def test_frozenset(self):
def test_dict(self):
self.assertIsSubclass(dict, typing.Dict)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_dict_subscribe(self):
K = TypeVar('K')
V = TypeVar('V')
Expand Down Expand Up @@ -6706,8 +6685,6 @@ def test_no_async_generator_instantiation(self):
with self.assertRaises(TypeError):
typing.AsyncGenerator[int, int]()

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_subclassing(self):

class MMA(typing.MutableMapping):
Expand Down Expand Up @@ -7736,8 +7713,6 @@ class ChildWithInlineAndOptional(Untotal, Inline):
class Wrong(*bases):
pass

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_is_typeddict(self):
self.assertIs(is_typeddict(Point2D), True)
self.assertIs(is_typeddict(Union[str, int]), False)
Expand Down Expand Up @@ -9270,8 +9245,6 @@ def foo(arg) -> TypeGuard[int]: ...
with self.assertRaises(TypeError):
TypeGuard[int, str]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(TypeGuard), 'typing.TypeGuard')
cv = TypeGuard[int]
Expand Down Expand Up @@ -9322,8 +9295,6 @@ def foo(arg) -> TypeIs[int]: ...
with self.assertRaises(TypeError):
TypeIs[int, str]

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_repr(self):
self.assertEqual(repr(TypeIs), 'typing.TypeIs')
cv = TypeIs[int]
Expand Down
7 changes: 6 additions & 1 deletion vm/src/builtins/genericalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ use crate::{
};
use std::fmt;

static ATTR_EXCEPTIONS: [&str; 8] = [
// attr_exceptions
static ATTR_EXCEPTIONS: [&str; 12] = [
"__class__",
"__bases__",
"__origin__",
"__args__",
"__unpacked__",
"__parameters__",
"__typing_unpacked_tuple_args__",
"__mro_entries__",
"__reduce_ex__", // needed so we don't look up object.__reduce_ex__
"__reduce__",
Expand Down