在Python中,我们都知道从2015年开始提供的Type hints:
def greet(name: str) -> str:
return "Hello, " + name
我们也知道Function Annotations,特别是这里我指的是文本注释,比如:
def greet(name: "The name of the person to greet") -> str:
return "Hello, " + name
但是is it possible to use Type Hints 100 with a textual function annotation?
例如:
def greet(name: str, "The name of the person to greet") -> str:
return "Hello, " + name
最后一个会抛出一个错误.
我似乎在PEP或Python文档中找不到任何关于这是否可能的来源.虽然我没有特别深入地搜索,但我仍然希望能找到可能的答案.