Created
January 27, 2021 01:08
-
-
Save GoodManWEN/65464b2b3ed32c0c85d66e25002d417d to your computer and use it in GitHub Desktop.
PEP563 DEMO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 简单测试,只有一个文件A.py ,B.py不存在 | |
import typing | |
if typing.TYPE_CHECKING: | |
import B | |
class A: | |
def func(self , input:B.Bird): | |
return None | |
====================== | |
报错提示 | |
Traceback (most recent call last): | |
File "C:\Users\USER\Documents\test.py", line 6, in <module> | |
class A: | |
File "C:\Users\USER\Documents\test.py", line 8, in A | |
def func(self , input:B.Bird): | |
NameError: name 'B' is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment