-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Mypy does not produce an error when comparing NewTypes based on Decimal.
To Reproduce
from decimal import Decimal
from typing import NewType
# Comparing Decimal NewTypes is OK
FirstDecimal = NewType("FirstDecimal", Decimal)
SecondDecimal = NewType("SecondDecimal", Decimal)
FirstDecimal(Decimal("0.1")) == SecondDecimal(Decimal("0.1")) # ! mypy ok
# But comparing other NewTypes is not
FirstInt = NewType("FirstInt", int)
SecondInt = NewType("SecondInt", int)
FirstInt(1) == SecondInt(3) # mypy error
FirstString = NewType("FirstString", str)
SecondString = NewType("SecondString", str)
FirstString("bam") == SecondString("boo") # mypy errorExpected Behavior
Mypy produces Non-overlapping equality check for all three comparisons.
Actual Behavior
Mypy produces Non-overlapping equality check only for int and str NewTypes.
Your Environment
- Mypy version used: 1.1.1
- Mypy command-line flags:
--strict - Mypy configuration options from
mypy.ini(and other config files):
[tool.mypy]
strict = true
show_error_context = true
show_error_codes = true
- Python version used:
3.10.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong