“类型提示”:在代码中用注解(annotations)标明变量、函数参数和返回值等应当是什么类型,帮助阅读、协作与静态检查(如发现潜在类型错误);通常不改变运行时行为。(也常见于 Python 等语言的“渐进式类型”实践。)
/taɪp ˈhɪntɪŋ/
Add type hinting to the function so others can understand it quickly.
给这个函数加上类型提示,这样别人能更快看懂。
With proper type hinting, the linter can catch mismatched return types before the code is deployed.
有了合适的类型提示,代码在部署前,检查工具就能发现返回类型不匹配的问题。
由 type(类型)+ hint(提示)+ -ing(名词化/动名词后缀)构成,字面意思是“对类型进行提示”。在编程语境中,它与“静态类型检查”“渐进式类型(gradual typing)”的发展相关,并因 Python 社区(如相关提案与文档)而广为流行。