-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Default ignore overrides default select but explicit select overrides default ignore #1687
Comments
in 5.x it was changed such that explicit opt-ins are respected -- before they were silently treated as implicit |
fwiw you almost never need |
OK I guess this makes sense, I just expected otherwise and it wasn't obvious to find out when the error appeared on update. Thanks for the hint. |
lol why do I bother writing a changelog 🙃 |
I found the release notes after a bit of searching but even then the implications were not clear to me. |
how did you install flake8?
pip install flake8
unmodified output of
flake8 --bug-report
describe the problem
I'm seeing a strange behaviour with
select
/ignore
arguments and their defaults. I think it appeared in flake8 5.x and I believe it is neither documented nor intuitive (but I could be proven wrong).The
--help
menu displays the default values forignore
andselect
:As expected, explicitly passing those values in a config file leads to a behaviour identical to the default one:
is identical to
In both cases, the ignore value overrides the select value and
W503
errors are ignored.What comes as a surprise is that
select
passed explicitly, even if its value is the default one, is not overridden by defaultignore
.In this case, W503 is not ignored.
In other words, it looks like the precedence order is the following:
while one (I, at least) would expect
In the latter case, an explicit value would only override a default one, but would not interfere with
ignore
overridingselect
.Same applies if a code or class is added with
extend-select
(not with flake8 < 5, see below). It will only be ignored if explicitly added toignore
orextend-ignore
. I'm using the form withoutextend-
above for brevity.After further investigation, the behaviour is the same with earlier versions of flake8, except that the tests above will not show it because when the value passed as
select
is the same as the default, the option is ignored. This changed in flake8 5.x (#284, #1609). Modifyingselect
to something slightly different such asE,F,W,C9
instead ofE,F,W,C90
will show that explicit select ofW
overrides default ignore ofW503
.With flake8 4.x,
extend-select
doesn't seem to override defaultignore
while it does with flake8 5.x.I'm not sure what is intended and what is not, here.
In practice, the problem in my codebase appeared because the config file dates back to when
extend-select
didn't exist so we usedselect
and we had to specify all the default codes in there.extend-select
now allows us to only add the ones we want, therefore we don't have to specifyW
which would override default ignore ofW503
. So we can get away with it by switching toextend-select
.I still think this behaviour is strange but maybe I haven't dived long enough in the docs and I shouldn't be surprised the actual behaviour doesn't follow my expectations. Feel free to close. Thanks for reading. I hope I'm making sense.
The text was updated successfully, but these errors were encountered: