Currently, a local variable is give a single FQN (fully qualified name) throughout an entire function. This leads to some bad inferences, such as here (reduced from lib2to3.fixer_util.Assign):
def Assign(source):
if not isinstance(source, list):
source.prefix = " "
source = [source]
return Node(syms.atom, [Leaf(token.EQUAL)] + source)
In this particular case, the analysis would be better if the type annotations were precise:
This discussion probably doesn't apply to class/instance variables or to global (module) variables; they can be changed anywhere, so changing their type is usually bad style (the one exception being the use of None for uninitialized; but that's captured by the Optional[...] type annotation).
Currently, a local variable is give a single FQN (fully qualified name) throughout an entire function. This leads to some bad inferences, such as here (reduced from
lib2to3.fixer_util.Assign
):In this particular case, the analysis would be better if the type annotations were precise:
Alternatively, it would help if
pykythe
usedisinstance
in its analysis. But in general, multiple bindings of a local variable are problematic.SSA uses the Φ (Phi) function to combine the results of multiple branches, but there's nowhere to anchor the Φ assignment:
It seems that this requires a change to the Kythe data model, to allow a
ref
to be to multiple places:This discussion probably doesn't apply to class/instance variables or to global (module) variables; they can be changed anywhere, so changing their type is usually bad style (the one exception being the use of
None
for uninitialized; but that's captured by theOptional[...]
type annotation).