Conditional Class Substitution in `__new__`: AI's Type Inference Failure

When a metaclass's `__new__` method conditionally returns an entirely different class or a proxy object, AI often fails to infer the correct type for the created object. This leads to `AttributeError`s when subsequent code attempts to access attributes or methods based on an incorrect type assumption.

Sources

Open the full topic