Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. When I manually run
I still get an error for this line:
(Also for
popped, but I'm usingformatas the simpler example to get right first.)FWIW maybe the variable could be named
fmt? IMOmaybe_formatis a bit unwieldy and not all that helpful. Using an abbreviation intuitively conveys the idea that this is a more local use thanformat.Not sure how to fix that error I get -- maybe it wants an assignment to
formatin the unreachablecase _clause, or maybe we need to just addformat: str | None = Noneat the top (just beforematch) and just addassert format is not Nonevefore adding it to the set? Then we can get rid ofmaybe_formatagain.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's strange. I can reproduce your results locally if I use that command, but not if I run
mypy --config-file Tools/cases_generator/mypy.ini(which is the command we're running in CI). And I know that before I made the code changes,mypy --config-file Tools/cases_generator/mypy.iniwas resulting inpossibly-undefinederrors on these lines.I wonder why the two commands are leading to different results? It seems very odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hauntsaninja, any idea what might be going on here? :)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff would fix the error you're seeing when you're running mypy with the different invocation, but I still don't understand why the two different mypy invocations are producing different results (and the errors you're seeing with the different mypy invocation feel spurious, since mypy's well aware that these
matchstatements are exhaustive):Possible fix:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I comment out
warn_unreachable = Truein the mypy.ini file, it produces those warnings. So that flag may not mean what we think it means.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we simultaneously figured this out here 😄
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that's weird. Not familiar with the undefined stuff, let me go get pdb out from my closet
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISTM that there are probably two mypy bugs we've stumbled upon here (☹️ ):
--warn-unreachableshould never be making errors go away: if mypy reports these errors without--warn-unreachable, it should probably report them with--warn-unreachableas wellpossibly-undefinederrors with or without--warn-unreachablespecified, since mypy's well aware that thesematchstatements are exhaustive, so it's not possible to get to the end of thematch thingstatement withoutformatbeing assigned to.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the comment earlier that was a repeat of what you already found, my Github was stale.
I need to get back to work, but it looks like there's some sort of side-effect-y message filtering that's going on in a place that to me seems like it absolutely should not have side effects. This diff makes mypy consistently not error:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some more time to look at this, I think python/mypy#15995 should fix