| 1 |
[case testCallGlobalFunction] |
| 2 |
def f() -> None: |
| 3 |
g() |
| 4 |
|
| 5 |
def g() -> None: |
| 6 |
pass |
| 7 |
[out] |
| 8 |
2:4:__main__.g |
| 9 |
|
| 10 |
[case testCallMethod] |
| 11 |
def f() -> None: |
| 12 |
c = C() |
| 13 |
if int(): |
| 14 |
c.method() |
| 15 |
|
| 16 |
class C: |
| 17 |
def method(self) -> None: pass |
| 18 |
[out] |
| 19 |
2:8:__main__.C |
| 20 |
3:7:builtins.int |
| 21 |
4:8:__main__.C.method |
| 22 |
|
| 23 |
[case testCallStaticMethod] |
| 24 |
class C: |
| 25 |
def f(self) -> None: |
| 26 |
C.static() |
| 27 |
self.static() |
| 28 |
|
| 29 |
@classmethod |
| 30 |
def cm(cls) -> None: |
| 31 |
cls.static() |
| 32 |
|
| 33 |
@staticmethod |
| 34 |
def static() -> None: pass |
| 35 |
[builtins fixtures/classmethod.pyi] |
| 36 |
[out] |
| 37 |
3:8:__main__.C |
| 38 |
3:8:__main__.C.static |
| 39 |
4:8:__main__.C.static |
| 40 |
8:8:__main__.C.static |
| 41 |
|
| 42 |
[case testCallClassMethod] |
| 43 |
class C: |
| 44 |
def f(self) -> None: |
| 45 |
C.cm() |
| 46 |
self.cm() |
| 47 |
|
| 48 |
@classmethod |
| 49 |
def cm(cls) -> None: |
| 50 |
cls.cm() |
| 51 |
[builtins fixtures/classmethod.pyi] |
| 52 |
[out] |
| 53 |
3:8:__main__.C |
| 54 |
3:8:__main__.C.cm |
| 55 |
4:8:__main__.C.cm |
| 56 |
8:8:__main__.C.cm |
| 57 |
|
| 58 |
[case testTypeVarWithValueRestriction] |
| 59 |
from typing import TypeVar |
| 60 |
|
| 61 |
T = TypeVar("T", "C", "D") |
| 62 |
|
| 63 |
def f(o: T) -> None: |
| 64 |
f(o) |
| 65 |
o.m() |
| 66 |
o.x |
| 67 |
|
| 68 |
class C: |
| 69 |
x: int |
| 70 |
def m(self) -> None: pass |
| 71 |
|
| 72 |
class D: |
| 73 |
x: str |
| 74 |
def m(self) -> None: pass |
| 75 |
[out] |
| 76 |
3:4:typing.TypeVar |
| 77 |
3:0:__main__.T |
| 78 |
6:4:__main__.f |
| 79 |
7:4:__main__.C.m |
| 80 |
8:4:__main__.C.x |
| 81 |
6:4:__main__.f |
| 82 |
7:4:__main__.D.m |
| 83 |
8:4:__main__.D.x |