| [case testEmptyFile] |
| [out] |
| -- Note that builtins are ignored to simplify output. |
| __main__: |
| SymbolTable() |
| |
| [case testVarDef] |
| x = 1 |
| [out] |
| __main__: |
| SymbolTable( |
| x : Gdef/Var (__main__.x)) |
| |
| [case testFuncDef] |
| def f(): pass |
| [out] |
| __main__: |
| SymbolTable( |
| f : Gdef/FuncDef (__main__.f)) |
| |
| [case testEmptyClassDef] |
| class c: pass |
| [out] |
| __main__: |
| SymbolTable( |
| c : Gdef/TypeInfo (__main__.c)) |
| |
| [case testImport] |
| import m |
| [file m.py] |
| x = 1 |
| [out] |
| __main__: |
| SymbolTable( |
| m : Gdef/MypyFile (m)) |
| m: |
| SymbolTable( |
| x : Gdef/Var (m.x)) |
| |
| [case testImportFromModule] |
| from m import x |
| [file m.py] |
| class x: pass |
| y = 1 |
| [out] |
| __main__: |
| SymbolTable( |
| x : Gdef/TypeInfo (m.x)) |
| m: |
| SymbolTable( |
| x : Gdef/TypeInfo (m.x) |
| y : Gdef/Var (m.y)) |
| |
| [case testImportAs] |
| from m import x as xx |
| [file m.py] |
| class x: pass |
| y = 1 |
| [out] |
| __main__: |
| SymbolTable( |
| xx : Gdef/TypeInfo (m.x)) |
| m: |
| SymbolTable( |
| x : Gdef/TypeInfo (m.x) |
| y : Gdef/Var (m.y)) |
| |
| [case testFailingImports] |
| from sys import non_existing1 # type: ignore |
| from xyz import non_existing2 # type: ignore |
| if int(): |
| from sys import non_existing3 # type: ignore |
| import non_existing4 # type: ignore |
| [out] |
| __main__: |
| SymbolTable( |
| non_existing1 : Gdef/Var (__main__.non_existing1) : Any |
| non_existing2 : Gdef/Var (__main__.non_existing2) : Any |
| non_existing3 : Gdef/Var (__main__.non_existing3) : Any |
| non_existing4 : Gdef/Var (__main__.non_existing4) : Any) |
| sys: |
| SymbolTable( |
| platform : Gdef/Var (sys.platform) |
| version_info : Gdef/Var (sys.version_info)) |
| |
| [case testDecorator] |
| from typing import Callable |
| |
| def dec(f: Callable[[], None]) -> Callable[[], None]: |
| return f |
| |
| @dec |
| def g() -> None: |
| pass |
| [out] |
| __main__: |
| SymbolTable( |
| Callable : Gdef/Var (typing.Callable) |
| dec : Gdef/FuncDef (__main__.dec) : def (f: def ()) -> def () |
| g : Gdef/Decorator (__main__.g) : def ()) |