Skip to content

Incompatible types in assignment Tuple[bool, bool, bool, int] #6805

Closed
@daevski

Description

@daevski
  • Are you reporting a bug, or opening a feature request?
    Bug

  • Please insert below the code you are checking with mypy...

from typing import Tuple 

_behaviors = dict(headless=False, verbose=False,
                 dryrun=False, timeout=30)

print(type(_behaviors['headless']))  # bool
print(type(_behaviors['verbose']))  # bool
print(type(_behaviors['dryrun']))  # bool
print(type(_behaviors['timeout']))  # int

options: Tuple[bool, bool, bool, int] = (
        _behaviors['headless'], _behaviors['verbose'],
        _behaviors['dryrun'], _behaviors['timeout'])
  • What is the actual behavior/output?

sample.py:11: error: Incompatible types in assignment (expression has type "Tuple[int, int, int, int]", variable has type "Tuple[bool, bool, bool, int]")

  • What is the behavior/output you expect?
    I wouldn't expect mypy to see 'options' variable as Tuple[int, int, int, int], but rather Tuple[bool, bool, bool, int]

  • What are the versions of mypy and Python you are using?
    Python 3.7.1
    mypy 0.701

  • Do you see the same issue after installing mypy from Git master?
    yes

  • What are the mypy flags you are using? (For example --strict-optional)
    This occurs without any flags

Screenshot attached for some visuals. (The small script above is a simplified repro that still causes the error.)

mypy-possible-bug

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