Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Mar 2, 2025
1 parent 97334a2 commit a104726
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion conformance/results/pyre/classes_classvar.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion conformance/tests/classes_classvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions docs/spec/class-compat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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``
Expand Down

0 comments on commit a104726

Please sign in to comment.