-
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
Refactor the DSLParser
state machine, removing self.next()
#14
Conversation
self.next()
self.next()
DSLParser
state machine, removing self.next()
I didn't take a close look yet (on mobil), but this looks promising. I find the naming slightly off, though. Wouldn't a |
|
Probably a more fundamental issue is that the |
And this of course brings us back to #4: the DSLParser class should probably also be in a separate module... |
Yes, we need to break the state machine out of |
0da42bf
to
91eefff
Compare
Coverage of the (This reveals another benefit of this PR: it exposes which situations aren't yet being considered by the clinic tests, by unraveling each possibility into a separate branch. Currently all the |
91eefff
to
fe4cb1f
Compare
934f6fd
to
8268a29
Compare
Actually, my suggestion is not a very good one 😄 The parser state machine of course needs to stay in the DSLParser. There is other stuff we can separate out, though. |
After studying the code for a while, I decided that both of the uncovered branches were in fact unreachable -- which indicates that the way the current code in |
Well, in a classic state machine, having "setup" states (like param-docstring-start) is IMO correct use of the state machine :) |
fbdfa5e
to
9dc86c8
Compare
Okay, following 9dc86c8, there are now no significant new uncovered lines in this PR! (To get there, I had to reintroduce some indirection, which I don't love... but you can't always get what you want :) There are still one or two small changes that can be broken out separately, though; I'll see about doing that. |
I'll have a look later (possibly tonight)! |
b5a5881
to
5a3230b
Compare
5a3230b
to
37b98ff
Compare
I don't like the current way the state machine works, at all. The indirection via
self.next()
is a leaky abstraction, as thestate_foo
methods don't really have the same signature at all (or shouldn't, at least). It's also really hard to get your head around and understand if you're not familiar with how clinic works (as I wasn't, until a month or two ago!).With this refactor, the
state_foo
methods (which are renamed to behandle_foo
methods) are now able to have different type signatures, removing the need for constantassert function is not None
assertions everywhere.DSLParser
should not storefunction
as state #7