Open
Description
While working on #6421 I looked again at logic for storing symbols for local (function- or method-level) classes in prepare_class_def()
. The logic is too ad-hoc and needs to be cleaned up. Here are some points that should be fixed:
defn.fullname
andinfo.fullname()
should always coincideinfo.fullname()
prefix should coincide with the symbol table where the info is actually stored (for serialization)- things should work for double nested classes
- things should work in fine-grained mode
I think the logic should be as following. Consider this example:
class Out:
def meth(self) -> None:
class In:
def meth(self) -> None:
class C: pass
The class C
should be stored in its local namespace under name 'C'
. In addition it should be stored in the namespace of __main__.Out
under name 'C@5'
. info.fullname()
and defn.fullname
should be both '__main__.Out.C@5'
.