Skip to content

False-positive "Incompatible types in assignment" #9640

@bersbersbers

Description

@bersbersbers

Bug Report

I get a false-positive "Incompatible types in assignment" error.

To Reproduce

This is bug.py:

"""False-positive 'Incompatible types in assignment'."""
VAR = 0
VAR = "0"
  1. mypy bug.py

Expected Behavior

No error.

Actual Behavior

> mypy bug.py
bug.py:3: error: Incompatible types in assignment (expression has type "str", variable has type "int")
Found 1 error in 1 file (checked 1 source file)

> mypy bug.py --allow-redefinition
bug.py:3: error: Incompatible types in assignment (expression has type "str", variable has type "int")
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 0.790
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none that I am aware of
  • Python version used: 3.8.6
  • Operating system and version: some Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions