mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-45755: [typing] Reveal class attributes of generic in generic aliases in dir() (GH-29962)
(cherry picked from commit d6e1374716)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
This commit is contained in:
parent
9fe8fb74a1
commit
87539cc716
3 changed files with 17 additions and 0 deletions
|
|
@ -4994,6 +4994,17 @@ def test_special_attrs2(self):
|
|||
loaded = pickle.loads(s)
|
||||
self.assertIs(SpecialAttrsP, loaded)
|
||||
|
||||
def test_genericalias_dir(self):
|
||||
class Foo(Generic[T]):
|
||||
def bar(self):
|
||||
pass
|
||||
baz = 3
|
||||
# The class attributes of the original class should be visible even
|
||||
# in dir() of the GenericAlias. See bpo-45755.
|
||||
self.assertIn('bar', dir(Foo[int]))
|
||||
self.assertIn('baz', dir(Foo[int]))
|
||||
|
||||
|
||||
class AllTests(BaseTestCase):
|
||||
"""Tests for __all__."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue