Skip to content

Instantly share code, notes, and snippets.

@GoodManWEN
Created January 27, 2021 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodManWEN/65464b2b3ed32c0c85d66e25002d417d to your computer and use it in GitHub Desktop.
Save GoodManWEN/65464b2b3ed32c0c85d66e25002d417d to your computer and use it in GitHub Desktop.
PEP563 DEMO
# 简单测试,只有一个文件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