Skip to content

self.x: str = 1000. Why is this not an error? #7857

Closed
@kurtgn

Description

@kurtgn

The question is basically in the header.

Why is this an error:

count: str = 1000  # expression has type "int", variable has type "str"

and this is not:

class Counter:
    def __init__(self):
        self.count: str = 1000
c = Counter()

I have the latest mypy as of today:

mypy 0.740 
├── mypy-extensions 0.4.3 
├── typed-ast 1.4.0
└── typing-extensions 3.7.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions