-
Notifications
You must be signed in to change notification settings - Fork 554
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
Run two different flake8 configs #1442
Conversation
I like this idea, but can you please provide a bit more info as to why certain tests have been selected to be ignored? For example, why is E741 ignored? I'm not saying I disagree with it being ignored, only we need why certain tests are ignored to be documented. Perhaps the reasons are already documented but I don't know where? |
This PR is trying to set us on a path of continuous improvement where contributors can pick a few codes and fix all issues to those codes. Fixing all failing codes in a single PR will be difficult to review and by the time that PR is approved, there will already be git conflicts with other changes landed in the meantime. The reason for ignoring E741 is documented under |
Ok, I understand: you wish to suppress tests initially then incrementally test for them and fix them.
This cannot completely be the case as the entire code base is formatted with black and yet we still have issues! We have been using black since 5.0.0. Are we perhaps not using back with all style fixtures turned on in some way? @ashleysommer can you please comment on this PR and the black assertion? |
Not quite. The drone command is
|
OK, I understand now. We do format with black locally too, and I've run black on /test as well as /rdflib. So all of the repo has been black formatted recently, even if it's not being done with each Drone run. I'm ok with accepting your direction here, as long as @ashleysommer & @white-gecko are fine with the Drone changes as they really maintain that! |
@@ -1,6 +0,0 @@ | |||
# https://flake8.pycqa.org/en/latest/user/configuration.html |
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 would rather leave this in place unless it is causing specific problems. Otherwise black and flake8 will fight with each other about line length and I think it is better to have line length controlled by black than have it controlled by flake8.
The ideal is to eventually have everything compliant with flake8 config as per .flake8
. I check all patches I make with:
darker test/ rdflib/
git diff | flake8 --diff
And without this I will get errors about line length. I can manage this locally also if it has to be but I think the benefit of having this here is it kind of sets a shared goal/ideal of where we want to get to in terms of flake8.
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.
black is best-effort while flake8 is pass/fail. flake8 must be told that line length is 88 or it will assume its default value of 79. Black will try to make lines 88 characters but it will not flag lines that are longer than 88 characters that it can not autoformat to be 88 or less. So, the advantage of flake8 monitoring the line length is that it will be the squeaky wheel that asks the contributor to make a manual correction while black will not.
% cat really_long_line.py
# 1 2 3 4 5 6 7 8 9
# 3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
% black really_long_line.py
All done! ✨ 🍰 ✨
1 file left unchanged.
% flake8 --max-line-length=88
./really_long_line.py:1:89: E501 line too long (90 > 88 characters)
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.
But this is why the config disables E501 (the error raised in your example). The aim is to defer line length solely to black
, so that black will fail when it is unhappy, but flake8 won't care about line length (except if you have flake8-black
in which case it will tell you that black is unhappy).
With no .flake8
config, if I develop on my machine, the default flake8 config will apply, which will complain a lot about line length, and this will not work well:
darker test/ rdflib/
git diff | flake8 --diff
because darker will use black's logic to determine line length, and flake8 will think it is wrong.
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.
The other option is to put max-line-length=1656
in the config (i.e. .flake8
) but I'm not sure that is better because effectively that disables E501
for most practical cases, and it may just be better to not have the check to begin with.
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.
Best practice is to work on decreasing the max-line-length with warnings about any transgressions instead of continuing to ignoring all test results with —exit-zero and || true.
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 not arguing we should keep --exit-zero
or || true
. I'm saying we should decide if black will control the line length or flake8, and we should then configure .flake8
accordingly. Like I said, if you feel that max-line-length=1656
makes more sense in .flake8
than ignoring E501
that is fine, but if you put neither down, then flake8 and black will be trying to do two very different things.
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.
The benefit I feel that ignoring E501
has over trying to clamp the line length with flake8 is that black will already clamp line length for code while E501 will make flake8 complain about comments also, and in some cases URLs in comments exceed the 80 default line length and it is quite annoying to have to work around this. But even so, if you want to put the recommended settings for black in .flake8
I will be fine with that also.
But not putting anything in config does not resolve the inherent disagreement that flake8 and black has about line length by default.
@cclauss I see you've also closed this PR. I hope you've not decided to keep supporting the improvements you've suggested here! We may have to work out details still, such as the points about line length above, but it doesn't mean we don't want the PR merged in some form. Or perhaps you're shifting some of these edits to another PR? |
Related to #1438 (comment)
This will allow us to remove ignored tests gradually over multiple PRs that are easier to review and merge.
Proposed Changes
Run two flake8 commands: 1) Just /rdflib, 2) The whole repo