报告 ClassVar 注解的无效用法。

示例:


from typing import ClassVar


class Cat:
    color: ClassVar[str] = "white"
    weight: int

    def __init__(self, weight: int):
        self.weight = weight


Cat.color = "black"  # OK
my_cat = Cat(5)
my_cat.color = "gray"  # 错误,在实例上设置类变量