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
I encountered this issue in working on #3435 -- it is the reason that PR stops short of implementing support for module aliasing assignment outside of module global scope. When I remove the not self.is_module_scope() guard in that PR, this line in the added test fails with an opaque error A: main:5: error: Member "m2" is not assignable.
I haven't yet traced through to fully understand what is happening, but I have a strong suspicion that the problem is due to SymbolTableNode.kind representing orthogonal characteristics of the symbol table node with mutually exclusive enum values.
This enum isn't capable of representing the fact that a MODULE_REF might occur at global, member, or local level. In the test linked above, I think the symbol table entry really should be both MDEF and MODULE_REF, but that isn't representable; when my code tries to change the class attribute symbol table node from MDEF to MODULE_REF, things break. I think mypy implicitly assumes that MODULE_REF is global.
Hopefully I can find time to explore this further, verify the suspicion, and investigate possible solutions. Just wanted to record my findings so far publicly before leaving PyCon sprint. Comments/guidance welcome!
The text was updated successfully, but these errors were encountered:
Closing this issue, it was bogus. The symptom is real (and fixed in #3450), but the speculation about the root cause was unfounded. These enum values are still pretty confusing, though.
I encountered this issue in working on #3435 -- it is the reason that PR stops short of implementing support for module aliasing assignment outside of module global scope. When I remove the
not self.is_module_scope()
guard in that PR, this line in the added test fails with an opaque errorA: main:5: error: Member "m2" is not assignable
.I haven't yet traced through to fully understand what is happening, but I have a strong suspicion that the problem is due to
SymbolTableNode.kind
representing orthogonal characteristics of the symbol table node with mutually exclusive enum values.SymbolTableNode.kind
can take one of these values: https://github.com/python/mypy/blob/master/mypy/nodes.py#L34-L53This enum isn't capable of representing the fact that a
MODULE_REF
might occur at global, member, or local level. In the test linked above, I think the symbol table entry really should be bothMDEF
andMODULE_REF
, but that isn't representable; when my code tries to change the class attribute symbol table node fromMDEF
toMODULE_REF
, things break. I think mypy implicitly assumes thatMODULE_REF
is global.Hopefully I can find time to explore this further, verify the suspicion, and investigate possible solutions. Just wanted to record my findings so far publicly before leaving PyCon sprint. Comments/guidance welcome!
The text was updated successfully, but these errors were encountered: