Teach the SymbolVisitor about more statements and expressions that can define symbols (original) (raw)
The SymbolVisitor in the ty_ide crate is much less exhaustive than the ExportFinder in the ty_python_semantic crate:
- It does not recognise that
type X = intdefines a symbolX - It does not recognise that
for x in range(42)defines a symbolx - It does not recognise that
case bar:in amatchstatement will define a symbolbar - It does not recognise that
with expr as whateverwill define a symbolwhatever - It does not recognise that
(y := []).append(42)defines a symboly - (There are more)
Most of these are edge cases that won't usually occur in the global scope in well-written Python code. But some of them (e.g. the type X = int case) are reasonable things that could well occur in well-written code. And the most important thing here, in my opinion, is for the two crates to have a consistent understanding of which symbols will be potentially imported by a * import. Currently ty_python_semantic does a much more rigorous job here at attempting to emulate the runtime semantics.
Cc. @BurntSushi