add standalone command line args#163
Conversation
334c495 to
4eb714c
Compare
jakkdl
left a comment
There was a problem hiding this comment.
Lots of minor stuff getting renamed in a million places, but also some substantive changes hidden in the diffs 🙃
flake8_trio/base.py
Outdated
|
|
||
| @dataclass | ||
| class Options: | ||
| # enable and disable have been expanded to contain full codes, and have no overlap |
There was a problem hiding this comment.
not sure having both enable and disable is any upside. And if anything should have a enabled_or_autofixed ?
There was a problem hiding this comment.
I'd also find it useful to comment on what autofix means here. Might be good to have a more substantial docstring?
And non-redundant data structures are good in general, "make illegal states unrepresentable" etc.
There was a problem hiding this comment.
ye I realized as I wrote my comment that it was bad design, also renamed the variables and improved comments.
flake8_trio/runner.py
Outdated
|
|
||
| class Flake8TrioRunner(ast.NodeVisitor): | ||
| def __init__(self, options: Namespace): | ||
| class CommonRunner(ABC): # noqa: B024 # no abstract methods |
There was a problem hiding this comment.
split out so selected doesn't have to be updated in two places
There was a problem hiding this comment.
If there are no abstract methods, we don't need to inherit from ABC, right?
There was a problem hiding this comment.
hm, I like showing in some way that it's not meant to be used/constructed directly .. but I guess I can give it a docstring saying so and add a double underscore to the name. If it was referenced outside the module it'd certainly want to inherit from ABC, but I suppose in that case it's likely it has a method that can be @abstracted
| # flake8 6 added a required named parameter formatter_names | ||
| def _default_option_manager(): | ||
| kwargs = {} | ||
| if flake8_version_info[0] >= 6: | ||
| kwargs["formatter_names"] = ["default"] | ||
| return OptionManager(version="", plugin_versions="", parents=[], **kwargs) | ||
|
|
||
|
|
There was a problem hiding this comment.
hell yes! Begone!
That ... might mean we can get rid of some stubs? and I'm not sure we need to parametrize tests on flake8 anymore, though I guess it doesn't really hurt
There was a problem hiding this comment.
My usual approach here is to keep the extra tests until the first time you find them annoying, and then delete them unless they've also been useful by then. Maximally lazy development!
There was a problem hiding this comment.
it doubles runtime of tests in CI, which definitely is quite annoying. I guess one could rejig the CI to run flake8_5 separately, but eh...
Zac-HD
left a comment
There was a problem hiding this comment.
Looks good to me; some comments below but feel free to merge when you've addressed them (or decided not to) to your satisfaction 👍
flake8_trio/base.py
Outdated
|
|
||
| @dataclass | ||
| class Options: | ||
| # enable and disable have been expanded to contain full codes, and have no overlap |
There was a problem hiding this comment.
I'd also find it useful to comment on what autofix means here. Might be good to have a more substantial docstring?
And non-redundant data structures are good in general, "make illegal states unrepresentable" etc.
flake8_trio/runner.py
Outdated
|
|
||
| class Flake8TrioRunner(ast.NodeVisitor): | ||
| def __init__(self, options: Namespace): | ||
| class CommonRunner(ABC): # noqa: B024 # no abstract methods |
There was a problem hiding this comment.
If there are no abstract methods, we don't need to inherit from ABC, right?
| # flake8 6 added a required named parameter formatter_names | ||
| def _default_option_manager(): | ||
| kwargs = {} | ||
| if flake8_version_info[0] >= 6: | ||
| kwargs["formatter_names"] = ["default"] | ||
| return OptionManager(version="", plugin_versions="", parents=[], **kwargs) | ||
|
|
||
|
|
There was a problem hiding this comment.
My usual approach here is to keep the extra tests until the first time you find them annoying, and then delete them unless they've also been useful by then. Maximally lazy development!
tests/test_flake8_trio.py
Outdated
| for code in enable_codes.split(","): | ||
| if error.code.startswith(code): |
There was a problem hiding this comment.
I'm concerned that a repeated-comma typo would enable everything here, might be worth checking that the code starts with TRIO?
There was a problem hiding this comment.
got confused for a moment that this was talking about the user-supplied string, but added tests that it won't break for users, and improved logic in the test so it'll warn about bad codes.
And just for funsies let's open a fourth PR 😁
It's branched on top of #162, so the diff will be slightly smaller once that's merged.
Ready for review, though I can probably polish it a bit if giving it another look tomorrow.
Had a decently long thonk on whether to just have an
--enableand no--disable, or whether to get the full flake8 experience with--extend-[...]flags. Settled on this compromise.91x does not respect
--autofixparameter value properly atm, hence the commented out code with that, would like #159 in order to work on that.Will probably have some merge conflicts and need rebasing once other PR's get merged