blob: 1622fd1f1ad4ac0e1846837e89e9c998fa7ae33e [file] [log] [blame] [edit]
[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) : builtins.int)
[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) : builtins.int)
[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) : builtins.int)
[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) : builtins.int)
[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)
[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) : builtins.int
dec : Gdef/FuncDef (__main__.dec) : def (f: def ()) -> def ()
g : Gdef/Decorator (__main__.g) : def ())