Run mypy_primer on push / Run mypy_primer on push (push) Has been cancelled
Validation / Typecheck (push) Has been cancelled
Validation / Style (push) Has been cancelled
Validation / Test macos-latest (push) Has been cancelled
Validation / Test ubuntu-latest (push) Has been cancelled
Validation / Test windows-latest (push) Has been cancelled
Validation / Build (push) Has been cancelled
Validation / Required (push) Has been cancelled
17 lines
441 B
Plaintext
17 lines
441 B
Plaintext
# 测试字符串注解(前向引用)的循环依赖支持
|
|
# 期望:k: 'a' 能正确解析为类 a 自身类型
|
|
|
|
class a:
|
|
k: 'a' # 字符串注解,引用类自身(循环依赖)
|
|
next: 'a | None' # 字符串注解中的类型组合
|
|
|
|
class Node:
|
|
value: int
|
|
next: 'Node' # 链表节点的循环引用
|
|
|
|
# 测试:实例化后访问字段
|
|
def test() -> int:
|
|
n: Node = Node()
|
|
n.value = 42
|
|
return n.value
|