Helpers to generate python lockfile rules#17480
Conversation
485e4c4 to
1773456
Compare
5bf81e7 to
cac4900
Compare
55e8fe7 to
951ab9f
Compare
|
Is there a chance I could convince you to rewrite history here so commits could be reviewed in order?
That'd make it much easier to review 😄 |
b9a2e7f to
574f1f2
Compare
|
sure, makes sense. full history available here |
574f1f2 to
3af161e
Compare
|
Will try and review properly today, but I love the idea so far! Take that, boilerplate. |
|
I think that CI failure isn't related to this MR? (failure is in Scala) |
Yea, looks like a flake. Have added a category label and restarted this. |
|
I'm not sure which test failed? there's 100% pass but it says it failed? |
looks like another flake.. kicked it again. |
benjyw
left a comment
There was a problem hiding this comment.
This looks great! And the proof of the pudding is in the eating. If all the tests pass, I'm happy pretty much by definition...
| ... | ||
|
|
||
|
|
||
| def rules(): |
There was a problem hiding this comment.
Thanks for writing up these great docs!
|
Throwing a couple more reviewers on, for perspective. |
There weren't that many tests for this with the other tools. I guess since most of this was boilerplate, people didn't feel the need to test it? But with the tests for Cowsay and Flake8 I think we're well-covered. |
|
And presumably you've manually tested |
|
I've run |
|
@thejcannon @kaos I'll merge this on Tuesday if no comments from you before then. Thanks!! |
|
Yeah sorry, been in the hospital since my last comment. Tuesday is my first day back at work, so I'll try and squeeze in this PR. |
|
Not urgent!! |
3af161e to
609bed2
Compare
thejcannon
left a comment
There was a problem hiding this comment.
We're close, I can taste it. I can't thank you enough for getting this together, I'm VERY excited at the prospect of more boilerplate-reducers.
f17c103 to
39033ea
Compare
| if self == LockfileRules.NONE: | ||
| return | ||
|
|
||
| yield from lockfile.rules() |
There was a problem hiding this comment.
I still don't think this is necessary. I understand it's useful for tests, but let's not pollute the code and confuse authors (and removing this removes the need for None).
There was a problem hiding this comment.
I thought so too. They're registered in the Python backend so they should be included. But the core doesn't register them, because it doesn't pull in the full python backend; it selectively pulls in YAPF and Black for updating build files. These would have then pulled in the lockfile.rules().
I've pulled this up to the root register in core, hopefully that gets the tests passing.
There was a problem hiding this comment.
In that case, I think the black/yapf backends should be re-registering these rules.
they're included upstream, only need to be added for tests
TODO: port to generic tool
helps with debugging
helps for opt-in and also doesn't generate rules for unsupported types
These rules were transitively included through core/register.py -> core/goals/update_build_files.py -> backend/python/lint/yapf/subsystem.py
update_build_files goal is the one that uses them, so it should register them there.
…o_lockfile_request
resolves runtime import
4164ab6 to
a98e001
Compare
They were already transitively imported through their subsystems. This MR pulls them up explicitly, so we need to allow that in the visibility rules
a98e001 to
cd88e04
Compare
|
I think that's a flaky test? It seems to work fine locally... |
|
Yeah, that test is flaky, I will look into fixing or kililng it. Meanwhile I've restarted that shard. |
|
Merged, finally! Thanks again for the contribution and for your patience! |
Breakout from #16412
Adds helpers to generate common python lockfile rules. includes:
GeneratePythonLockfile.from_toolI threw together some documentation, but I'm not sure where these would go or even if they're what we want.
I'm also not sure how we want to fail generating rules if the fields we need aren't present. For example, for tools which need interpreter constraints, their
FieldSetneeds to have anInterpreterConstraintsFieldattribute; how should we warn if that field isn't present?Talking things over with @thejcannon , we think that we'd need to do some prework to support a design similar to the other rule generators. Having a declarative field on the class would be ideal. However, we would need to tether a tool to its fieldset to support usecases 2 and 3, which is where the prework would come in.
This MR now deals only with the first case. This is basically 60% of usecases and probably most of the uses in plugins.