You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2021-12-16.14:35:18.244>created_at=<Date2021-11-08.19:30:49.749>labels= ['type-bug', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
title='Specialized generic class does not return class attributes in dir'updated_at=<Date2021-12-17.11:33:23.239>user='https://bugs.python.org/kjamieson'
This worked in Python 3.6, but in Python 3.7 and later creating a mock with a spec specifying a subscripted generic class does not mock any of the attributes of the class, because those attributes are not returned by dir().
# python3.11 test.py
Traceback (most recent call last):
File "/root/test.py", line 11, in <module>
File "/usr/lib/python3.11/unittest/mock.py", line 635, in __getattr__raiseAttributeError("Mock object has no attribute %r"% name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AttributeError: Mock object has no attribute 'bar'
This seems to be an issue with typing than mock since mock just uses the output from dir() . I am not able to bisect the relevant change but below is the output of dir(Foo[int]) in Python 3.6 and master.