You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mypy raises call-overload when attempting to call an overloaded superclass constructor, if the overload hinges on literal True and False values and the call passes a bool value.
Please note: this is intended as a minimal example, not as an interesting example. I am happyt to produce interesting examples if they provide additional motivation to tackle this issue.
Expected Behavior
Because the bool type is fully covered by the Literal[True] and Literal[False] cases, it should be possible for Mypy to infer that the call super().__init__(x) is correct in the B constructor.
Actual Behavior
No overload variant of "__init__" of "A" matches argument type "bool"
Possible overload variants:
def __init__(self, x: Literal[True]) -> None
def __init__(self, x: Literal[False] = ...) -> NoneMypy
Your Environment
Mypy version used: mypy 1.7.1 (compiled: yes)
Mypy command-line flags: --strict
Python version used: 3.12.0 64-bit
The text was updated successfully, but these errors were encountered:
sg495
changed the title
Call-overload error when calling overloaded constructors which involve exhaustive Literal cases (e.g. for bool type argument)
(🐞) call-overload error when calling overloaded constructors which involve exhaustive Literal cases (e.g. for bool type argument)
Jan 13, 2024
Bug Report
Mypy raises
call-overload
when attempting to call an overloaded superclass constructor, if the overload hinges on literalTrue
andFalse
values and the call passes abool
value.This is related to issue #8330
To Reproduce
Please note: this is intended as a minimal example, not as an interesting example. I am happyt to produce interesting examples if they provide additional motivation to tackle this issue.
Expected Behavior
Because the
bool
type is fully covered by theLiteral[True]
andLiteral[False]
cases, it should be possible for Mypy to infer that the callsuper().__init__(x)
is correct in theB
constructor.Actual Behavior
Your Environment
mypy 1.7.1 (compiled: yes)
--strict
The text was updated successfully, but these errors were encountered: