`__static_attributes__` class attribute from Python 3.13
Python 3.13 introduced __static_attributes__ special attribute for classes. The trick is - it is not defined on object ...
AttributeError: type object 'object' has no attribute '__static_attributes__'
What is the best way to declare it in typeshed? As object attribute anyway? Or there is no way atm?
I believe it's only defined on pure-Python classes, which isn't expressible in the type system. Probably the only safe way of accessing this attribute is by doing something like getattr(obj, "__static_attributes__", ()), which I think means we maybe shouldn't add it to typeshed. On the mypy master branch, stubtest already knows not to emit an error if the attribute's not there, and we're using the mypy master branch for our stubtest checks in CI at the moment.
There's a similar situation with the new __firstlineno__ class attribute, also added in py313.
The same thing is true for type.__abstractmethods__, which is not in the stub.
We usually tend to add sometimes-defined attributes (with a comment) on the policy that false negatives are preferable to false positives. That said, maybe it's time to turn python/typing#601 into a PEP to formalize this behavior.
Could Python define __static_attributes__ as an empty tuple for C extension classes? Then we could easily type it.