如何正确注释 class 实例

How to properly annotate a class instance

我正在阅读 PEP 526 文档,我想知道注释 class 实例的正确方法是什么。

我没有在文档中找到答案。

我有以下模块:

class global_variables:
     # Class body

global_variables_dictionary: global_variables = global_variables("application.yaml")

something: <class_name> = class_name() 这样做是正确的方法吗?

谢谢

是的。顺便提一句。您应该避免使用小写字母命名 类。关于 PEP,您应该使用驼峰式大小写:

Start each word with a capital letter. Do not separate words with underscores. This style is called camel case.

是的,这是正确的方式,但 class 我认为名称不应该是小写的。