-
Notifications
You must be signed in to change notification settings - Fork 0
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
DSLParser: pass function
as a parameter to all state_foo
methods
#13
Conversation
It looks like a big diff, but a lot of it is just me refusing to keep to the existing ~120-character line lengths for bits that I have to touch anyway with this refactor 😅 This doesn't get rid of all the Ultimately, if it's sometimes |
assert function is None | ||
|
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 assertion (and a few others I add in this PR) isn't actually necessary to keep mypy happy, but I think it's useful to assert exactly where we are in the state machine at this point. I.e., it's there as a sanity check and for readability.
function
as a parameterfunction
as a parameter to all state_foo
methods
Note: I haven't checked test coverage for all the lines I'm touching in this PR. Will do that before filing a PR to CPython -- if you like the overall idea here! |
return function | ||
|
||
def state_dsl_start(self, function: Function | None, line: str) -> Function | None: | ||
assert function is None |
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.
(Another assertion which isn't required for mypy, but which I added because I thought it provided clarity for human readers about where we are in the state machine)
I'll have a look later! Are you thinking of ripping out the state machine in the long term? |
Not sure... I do feel like the current way of calling all the Still, whatever the case, this change definitely makes me feel happier about the overall design. So I think it's a good step for now :) |
Actually, I'll just close this in favour of #14. I was expecting that to be a bigger diff than it was, but it's only a slightly bigger change than this one (and it's built on top of this one). It gets us to a much nicer place imo. |
Towards #7