GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-104504: cases generator: Add `--warn-unreachable` to the mypy config by AlexWaygood · Pull Request #108112 · python/cpython Conversation
|
| case parsing.Macro(): | ||
| format = self.macro_instrs[thing.name].instr_fmt | ||
| case parsing.Pseudo(): | ||
| format = None |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Similarly, here mypy was eagerly narrowing the type of format to None, meaning that it was inferring the else branch on line 396 to be unreachable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Still feels like a mypy bug to me, but your fix is fine.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@gvanrossum, are you happier with the new refactor? Now |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
(The test_concurrent_futures failure on Azure Pipelines is unrelated) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let's check this in.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # Calculate stack effect, and check that it's the the same | ||
| # for all targets. | ||
| for target in self.pseudos[thing.name].targets: | ||
| for idx, target in enumerate(self.pseudos[thing.name].targets): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Clever idea. I wrote a whole paragraph arguing against using enumerate() here, then realized it wasn't worth arguing over. :-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
FYI, the saga continues. Currently we get errors from pyright on this: "popped is possibly unbound" (on all occurrences of popped and pushed in this function below here).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
FYI, the saga continues. Currently we get errors from pyright on this: "popped is possibly unbound" (on all occurrences of popped and pushed in this function below here).
Yeah, and mypy will also give you that error if you add --enable-error-code=possibly-undefined to the mypy config :/
There is a third way of fixing this. I'll make a PR and see how you like it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| case parsing.Macro(): | ||
| format = self.macro_instrs[thing.name].instr_fmt | ||
| case parsing.Pseudo(): | ||
| format = None |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Still feels like a mypy bug to me, but your fix is fine.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the review! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if idx == 0: | ||
| format = target_instr.instr_fmt | ||
| else: | ||
| assert format == target_instr.instr_fmt | ||
| assert format is not None | ||
| case _: | ||
| typing.assert_never(thing) | ||
| assert_never(thing) | ||
| all_formats.add(format) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
And ditto here for format.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.