Skip to content

False negative for non-overlapping type check inside function with strict_equality flag #10055

Closed
@Garrett-R

Description

@Garrett-R

Bug Report

To Reproduce

Run this file to test.py:

if 'red' == 5:  # <-- Mypy finds error
    print('equal')

def foo():
    if 'red' == 5:  # <-- Mypy does not find error
        print('equal')

foo()

then execute

mypy test.py --strict-equality

Expected Behavior

Mypy should find 2 errors in this file.

Actual Behavior

Mypy fails to find the error inside the function.

Your Environment

  • Mypy version used: 0.8000
  • Mypy command-line flags: --strict-equality
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.9.1
  • Operating system and version: Ubuntu 18.04

Activity

hauntsaninja

hauntsaninja commented on Feb 9, 2021

@hauntsaninja
Collaborator
Garrett-R

Garrett-R commented on Feb 9, 2021

@Garrett-R
Author

Ah, my apologies! Thank you for your time and thanks for the package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @Garrett-R@hauntsaninja

        Issue actions

          False negative for non-overlapping type check inside function with strict_equality flag · Issue #10055 · python/mypy