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.Dismiss alert
So the only ways to create a type alias with a __module__ of choice is by managing globals()["__name__"] using e.g. eval(..., globals=...), temporarily setting globals()["name"] = ..., or defining a custom module with that __name__.
It would make more sense to just make __module__ mutable.
The
__module__attribute is readonly, and will always be derived usingcaller():cpython/Objects/typevarobject.c
Lines 2199 to 2202 in 16185e9
So the only ways to create a type alias with a
__module__of choice is by managingglobals()["__name__"]using e.g.eval(..., globals=...), temporarily settingglobals()["name"] = ..., or defining a custom module with that__name__.It would make more sense to just make
__module__mutable.