diff --git a/conformance/results/pyre/classes_classvar.toml b/conformance/results/pyre/classes_classvar.toml index b3302051..77c9e726 100644 --- a/conformance/results/pyre/classes_classvar.toml +++ b/conformance/results/pyre/classes_classvar.toml @@ -3,7 +3,6 @@ notes = """ Does not reject use of TypeVar in ClassVar. Does not reject use of ParamSpec in ClassVar. Does not reject use of ClassVar as a generic type argument. -Does not allow ClassVar to be used without an assigned value. Does not reject use of ClassVar in parameter type annotation. Does not reject use of ClassVar in local variable annotation. Does not reject use of ClassVar in instance variable annotation. diff --git a/conformance/tests/classes_classvar.py b/conformance/tests/classes_classvar.py index dca180af..2f6ed04f 100644 --- a/conformance/tests/classes_classvar.py +++ b/conformance/tests/classes_classvar.py @@ -63,7 +63,7 @@ class ClassA(Generic[T, P]): good4: ClassVar = 3.1 # > If the `ClassVar` qualifier is used without any assigned value, the type # > should be inferred as `Any`: - good5: ClassVar + good5: ClassVar #E? Type checkers may error on uninitialized ClassVar good6: Annotated[ClassVar[list[int]], ""] = [] def method1(self, a: ClassVar[int]): # E: ClassVar not allowed here diff --git a/docs/spec/class-compat.rst b/docs/spec/class-compat.rst index f898d6a9..2984c5a3 100644 --- a/docs/spec/class-compat.rst +++ b/docs/spec/class-compat.rst @@ -31,8 +31,9 @@ is enforced by static checkers, but not at runtime. inferred as some type to which this value is :term:`assignable` (for example, ``int``, ``Literal[2]``, or ``Any``). - If the ``ClassVar`` qualifier is used without any assigned value, the type - should be inferred as :ref:`any`. + If the bare ``ClassVar`` qualifier is used without any assigned value, the type + should be inferred as :ref:`Any `. Type checkers may error if no assigned + value is present. Type annotations can be used to annotate class and instance variables in class bodies and methods. In particular, the value-less notation ``a: int``