-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
add standalone command line args #163
Conversation
334c495
to
4eb714c
Compare
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
problems: list[Error] = field(default_factory=list) | ||
library: tuple[str, ...] = () | ||
typed_calls: dict[str, str] = field(default_factory=dict) | ||
variables: dict[str, str] = field(default_factory=dict) | ||
|
||
|
||
class Flake8TrioRunner(ast.NodeVisitor): | ||
def __init__(self, options: Namespace): | ||
class CommonRunner(ABC): # noqa: B024 # no abstract methods |
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.
split out so selected
doesn't have to be updated in two places
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.
If there are no abstract methods, we don't need to inherit from ABC, right?
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.
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 @abstract
ed
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
problems: list[Error] = field(default_factory=list) | ||
library: tuple[str, ...] = () | ||
typed_calls: dict[str, str] = field(default_factory=dict) | ||
variables: dict[str, str] = field(default_factory=dict) | ||
|
||
|
||
class Flake8TrioRunner(ast.NodeVisitor): | ||
def __init__(self, options: Namespace): | ||
class CommonRunner(ABC): # noqa: B024 # no abstract methods |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
--enable
and no--disable
, or whether to get the full flake8 experience with--extend-[...]
flags. Settled on this compromise.91x does not respect
--autofix
parameter 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