| 1 |
[case testAbstractMethods] |
| 2 |
from abc import abstractmethod, ABCMeta |
| 3 |
import typing |
| 4 |
|
| 5 |
class A(metaclass=ABCMeta): |
| 6 |
@abstractmethod |
| 7 |
def g(self) -> 'A': pass |
| 8 |
@abstractmethod |
| 9 |
def f(self) -> 'A': return self |
| 10 |
[out] |
| 11 |
MypyFile:1( |
| 12 |
ImportFrom:1(abc, [abstractmethod, ABCMeta]) |
| 13 |
Import:2(typing) |
| 14 |
ClassDef:4( |
| 15 |
A |
| 16 |
Keywords(metaclass=NameExpr(ABCMeta [abc.ABCMeta])) |
| 17 |
Metaclass(NameExpr(ABCMeta [abc.ABCMeta])) |
| 18 |
Decorator:5( |
| 19 |
Var(g) |
| 20 |
FuncDef:6( |
| 21 |
g |
| 22 |
Args( |
| 23 |
Var(self)) |
| 24 |
def (self: __main__.A) -> __main__.A |
| 25 |
Abstract |
| 26 |
Block:6( |
| 27 |
PassStmt:6()))) |
| 28 |
Decorator:7( |
| 29 |
Var(f) |
| 30 |
FuncDef:8( |
| 31 |
f |
| 32 |
Args( |
| 33 |
Var(self)) |
| 34 |
def (self: __main__.A) -> __main__.A |
| 35 |
Abstract |
| 36 |
Block:8( |
| 37 |
ReturnStmt:8( |
| 38 |
NameExpr(self [l]))))))) |
| 39 |
|
| 40 |
[case testClassInheritingTwoAbstractClasses] |
| 41 |
from abc import abstractmethod, ABCMeta |
| 42 |
import typing |
| 43 |
|
| 44 |
class A(metaclass=ABCMeta): pass |
| 45 |
class B(metaclass=ABCMeta): pass |
| 46 |
class C(A, B): pass |
| 47 |
[out] |
| 48 |
MypyFile:1( |
| 49 |
ImportFrom:1(abc, [abstractmethod, ABCMeta]) |
| 50 |
Import:2(typing) |
| 51 |
ClassDef:4( |
| 52 |
A |
| 53 |
Keywords(metaclass=NameExpr(ABCMeta [abc.ABCMeta])) |
| 54 |
Metaclass(NameExpr(ABCMeta [abc.ABCMeta])) |
| 55 |
PassStmt:4()) |
| 56 |
ClassDef:5( |
| 57 |
B |
| 58 |
Keywords(metaclass=NameExpr(ABCMeta [abc.ABCMeta])) |
| 59 |
Metaclass(NameExpr(ABCMeta [abc.ABCMeta])) |
| 60 |
PassStmt:5()) |
| 61 |
ClassDef:6( |
| 62 |
C |
| 63 |
BaseType( |
| 64 |
__main__.A |
| 65 |
__main__.B) |
| 66 |
PassStmt:6())) |
| 67 |
|
| 68 |
[case testAbstractGenericClass] |
| 69 |
from abc import abstractmethod |
| 70 |
from typing import Generic, TypeVar |
| 71 |
T = TypeVar('T') |
| 72 |
class A(Generic[T]): |
| 73 |
@abstractmethod |
| 74 |
def f(self) -> 'A[T]': pass |
| 75 |
[out] |
| 76 |
MypyFile:1( |
| 77 |
ImportFrom:1(abc, [abstractmethod]) |
| 78 |
ImportFrom:2(typing, [Generic, TypeVar]) |
| 79 |
AssignmentStmt:3( |
| 80 |
NameExpr(T* [__main__.T]) |
| 81 |
TypeVarExpr:3()) |
| 82 |
ClassDef:4( |
| 83 |
A |
| 84 |
TypeVars( |
| 85 |
T`1) |
| 86 |
Decorator:5( |
| 87 |
Var(f) |
| 88 |
FuncDef:6( |
| 89 |
f |
| 90 |
Args( |
| 91 |
Var(self)) |
| 92 |
def (self: __main__.A[T`1]) -> __main__.A[T`1] |
| 93 |
Abstract |
| 94 |
Block:6( |
| 95 |
PassStmt:6()))))) |
| 96 |
|
| 97 |
[case testFullyQualifiedAbstractMethodDecl] |
| 98 |
import abc |
| 99 |
from abc import ABCMeta |
| 100 |
import typing |
| 101 |
|
| 102 |
class A(metaclass=ABCMeta): |
| 103 |
@abc.abstractmethod |
| 104 |
def g(self) -> 'A': pass |
| 105 |
[out] |
| 106 |
MypyFile:1( |
| 107 |
Import:1(abc) |
| 108 |
ImportFrom:2(abc, [ABCMeta]) |
| 109 |
Import:3(typing) |
| 110 |
ClassDef:5( |
| 111 |
A |
| 112 |
Keywords(metaclass=NameExpr(ABCMeta [abc.ABCMeta])) |
| 113 |
Metaclass(NameExpr(ABCMeta [abc.ABCMeta])) |
| 114 |
Decorator:6( |
| 115 |
Var(g) |
| 116 |
FuncDef:7( |
| 117 |
g |
| 118 |
Args( |
| 119 |
Var(self)) |
| 120 |
def (self: __main__.A) -> __main__.A |
| 121 |
Abstract |
| 122 |
Block:7( |
| 123 |
PassStmt:7()))))) |