Skip to content

Bare ClassVar should infer type instead of defaulting to Any #5587

@ilevkivskyi

Description

@ilevkivskyi

Currently we have:

from typing import ClassVar
  
class C:
    x: ClassVar = 1

reveal_type(C.x)  # Revealed type is 'Any'

ClassVar is not a generic type (and not really a type, rather an access qualifier). So it will be better if a bare ClassVar would use inference instead of defaulting to Any thus reducing verbosity or false negatives (although --disallow-any-generics actually flags this).

Probably not high priority.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions