-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
False positive with warn-unreachable
and no-strict-optional
(canonical)
#16718
Comments
This is expected given that you're using |
Thanks! |
I don't think this should be closed. What change is the reason behind this new failure? For us the failing code is strictly typed def func(inp: str) -> str | None:
if re.match(MY_REGEX, inp):
return inp
return None # This errors as "unreachable" We have a pretty big codebase, where A LOT of code is still using |
Oh you didn't mention this was a regression. Looks like the relevant change is #16566, so mypy correctly sees that Match is final and cannot have a falsey subclass. I don't think there's any change to be made here. If this is a problem for your existing codebase, I recommend using |
Match may be final, but We're already using We can ignore this error on the impacted functions, but IMO this is a regression not a bug in our "outdated" codebase |
On multiple occasions, I've encountered folks using this, running into issues and then being perplexed when they figure out what `--no-strict-optional` actually does. Most recently in python#16718 (comment) This is a non-standard, dangerous option that should not be used in modern typed Python. It's been five and a half years since it was the default behaviour in mypy, so we should deemphasise and warn about its existence.
On multiple occasions, I've encountered folks using this, running into issues and then being perplexed when they figure out what `--no-strict-optional` actually does. Most recently in #16718 (comment) This is a non-standard, dangerous option that should not be used in modern typed Python. It's been five and a half years since it was the default behaviour in mypy, so we should deemphasise and warn about its existence.
warn-unreachable
and no-strict-optional
(canonical)
Bug Report
Tests with
re.match
orre.search
give incorrect unreachable error when using mypy 1.8.0To Reproduce
Expected Behavior
No mypy errors
Actual Behavior
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: