Overloaded signature with LiteralString
is seen as "broader or same" as str
#18584
Labels
LiteralString
is seen as "broader or same" as str
#18584
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
Expected Behavior
I expected mypy to see the overloads as being different so that a function passed literal inputs can propagate its output as also being literal (ie: not a user input). With a fallback to a regular
str
when the input isn't statically controlled.Pyright supports this. Results from Pylance:
Actual Behavior
Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overload-cannot-match
]In both cases:
Revealed type is "builtins.str"
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: