Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Python's ABCs should have__slots__ attributes to not interfere with slotting in derived classes (especially when the class has no members). However, it is not the case forcontextlib.ContextManager (as for othercontextlib ABCs):
fromtypingimportContextManagerclassA(ContextManager[int]):__slots__= ()__enter__=__exit__=lambda*args:NoneA().a=1# No exception
ChangingContextManager toMutableMapping, for example (and setting relevant dunders), does raise an exception.
Observed on Ubuntu 20.04 and Python 3.9.16.