Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using TypeVar as typing for a function argument disables the --strict-equality check #16477

Open
JaykeMeijer opened this issue Nov 13, 2023 · 0 comments
Labels
bug mypy got something wrong topic-overlap Overlapping equality check

Comments

@JaykeMeijer
Copy link

JaykeMeijer commented Nov 13, 2023

Bug Report

When using a TypeVar as typing for a function parameter, the --strict-equality checks are no longer executed.

To Reproduce

from typing import TypeVar

T = TypeVar("T", int, str)


def a(x: T) -> None:
    1 == "a"


def b(x: int | str) -> None:
    1 == "a"

a(1)
b(1)

Playground: https://mypy-play.net/?mypy=master&python=3.10&flags=strict&gist=60fa0e9e47a0ed5683357b1fa2611477

Expected Behavior

I would expect both functions a() and b() to raise the comparison-overlap error.

Actual Behavior

Only function b() where there is no TypeVar used raises the comparison-overlap error.

Note that other, standard, mypy checks are executed and flagged in both functions.

Your Environment

  • Mypy version used: Checked with multiple (1.4.1, 1.7.0, master branch)
  • Mypy command-line flags: --strict or --strict-equality
  • Mypy configuration options from mypy.ini (and other config files): -
  • Python version used: 3.10, 3.11
@JaykeMeijer JaykeMeijer added the bug mypy got something wrong label Nov 13, 2023
@AlexWaygood AlexWaygood added the topic-overlap Overlapping equality check label Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-overlap Overlapping equality check
Projects
None yet
Development

No branches or pull requests

2 participants