Skip to content
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

MAINT: do fewer style checks #531

Merged
merged 2 commits into from
Mar 20, 2024
Merged

Conversation

bsipocz
Copy link
Member

@bsipocz bsipocz commented Mar 6, 2024

This turns off check for foo/2vs foo / 2, but still keeps checking for spaces around operators for better legibility, e.g. foo < bar and not foo<bar.

Similarly, we keep foo = 2 while bar(foo=2).

#470 (comment)

@msdemlei - if you have other specific error code you would like to turn off, please comment them here. The whitespace in arithmetic is a typically problematic one, so I fully agree that we can turn that off, but I find the rest of the examples above useful choices.

@bsipocz bsipocz added this to the v1.5.2 milestone Mar 6, 2024
@bsipocz bsipocz requested a review from msdemlei March 6, 2024 16:22
@bsipocz bsipocz changed the title MAINT: do less style checks MAINT: do fewer style checks Mar 6, 2024
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.38%. Comparing base (4d31a06) to head (ded4360).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #531   +/-   ##
=======================================
  Coverage   80.38%   80.38%           
=======================================
  Files          52       52           
  Lines        6189     6189           
=======================================
  Hits         4975     4975           
  Misses       1214     1214           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As people who've seen me in real life will know I'm probably not the most likely candidate to comment on style issues :-). But I am keen on switching off E226, so thanks for that.

I've looked at the output of a plain flake8 pyvo --count on a current checkout of pyvo, and here's my opinions (i.e., feel free to ignore them) on the diagnostics:

  • E251 – I agree; I frankly can see scenarios when I might want to see whitespace for keyword defaults, but what I've spot-checked is not among them
  • E124, E127 – I'm not a fan of visual indentation at all, so it's no surprise I'm not wild about these. I'd give them a 6 on a pain level range of 0 to 10.
  • E123 – ok... wouldn't be my choice, but it doesn't seem unreasonable. Fine with me.
  • E122 – ah. pyvo/discover/image.py:253 is indeed indented misleadingly. This seems like a useful check :-)
  • E225 – the cases I spot-checked are ok, so I'm fine with keeping it on.
  • E501 – I'd even make that one stricter :-) I will admit that I think that in cases like pyvo/discover/tests/test_imagediscovery.py:130, where there's a string one might want to update from what the machine generates, I sometimes like to break my own holy rules, but that's really minor convenience.
  • E741 – that is: a variable name of l is off limits unconditionally? I mean, I won't publicly speak out in favour of variable names like "l", but forbidding them... I don't know. Still: pain level 0/10.

Thanks!

@bsipocz
Copy link
Member Author

bsipocz commented Mar 7, 2024

E501 – I'd even make that one stricter :-) I will admit that I think that in cases like pyvo/discover/tests/test_imagediscovery.py:130, where there's a string one might want to update from what the machine generates, I sometimes like to break my own holy rules, but that's really minor convenience.
E741 – that is: a variable name of l is off limits unconditionally? I mean, I won't publicly speak out in favour of variable names like "l", but forbidding them... I don't know. Still: pain level 0/10.

I have advocated for allowing longer lines as it helps with removing weird-looking and logically unnecessary line-breaks all the while most laptops and desktops come with a wide enough monitor to still allow two windows next to each other. So, I would like to keep the 110 characters as necessary.

As for single letter variables, the rule I believe comes from the ambiguity between l and I and more importantly (to me) to help with a quicker/easier search/replace. So, I would like to keep the rule as it may also help to prevent some bugs (anecdote only, but I recall we might have caught a few when this rule was turned on for the astropy core repo, but I may misremember)

I like the visual indent rules, but given their higher pain level and that it came up multiple times I would be OK to add them to the exception list.

@bsipocz
Copy link
Member Author

bsipocz commented Mar 7, 2024

@tomdonaldson @andamian - does this sound good to you?

@lmichel
Copy link
Contributor

lmichel commented Mar 8, 2024

Having got used to working with a much stricter Pylint on another project, I ended up considering that the cost/benefit ratio of these rules was very positive. There are two rules which, if ignored, could affect the clarity of the code in my opinion:

  • E124 (closing bracket does not match visual indentation) is sometime difficult to follow, especially when building dict. However, I think it provides a common rule to understand complex structures.
  • E127: (Continuation line over-indented) personaly I appreciate the vertical alignment of the function parameters

@andamian
Copy link
Contributor

I personally don't see a problem with E124 and E127. Sometimes E127 (Continuation line) gets on my nerves but it's for a good cause I think. Python is based on indentation, so why brake the flow with these exceptions?

@msdemlei
Copy link
Contributor

msdemlei commented Mar 13, 2024 via email

@andamian
Copy link
Contributor

I can't remember all the cases either. The ones in https://www.flake8rules.com/rules/E127.html and in the link provided make sense.

@bsipocz
Copy link
Member Author

bsipocz commented Mar 13, 2024

I also agree that E127 indentations are usually quite sensible, but also see the frustration for some of the recent cases when it's long string lines, etc.
So, if it was me, I would keep all these checks, but I'm happy to lift them if others find it helpful. (and as I said, my emacs flares up as a Christmas tree when I don't follow any of these rules, so an editor plugin can go a long way for ensuring the CI will pass on first try)

@msdemlei
Copy link
Contributor

msdemlei commented Mar 20, 2024 via email

@bsipocz
Copy link
Member Author

bsipocz commented Mar 20, 2024

I would say, let's go ahead with this PR to make life easier, and if it's too forgiving, we can always add back enforcing the line indents. (And of course, the skipped rules can still be followed even if we don't enforce them)

@bsipocz bsipocz merged commit 099c907 into astropy:main Mar 20, 2024
12 checks passed
@lmichel
Copy link
Contributor

lmichel commented Mar 20, 2024

The linter rules are easily reversible, so I see no reason to discuss more this PR.
I'd just like to give my point of view, which is that the blocking style rules must be chosen in such a way as to make the review work easier.
It's better to annoy coders a bit more with strict rules if it makes the reviewers' job easier.
This hardening would be acceptable if the GITHUB actions were modified so as to run falke8 on every push, whatever the branch. In this way, the MRs would only relate to clean code.

@bsipocz bsipocz deleted the MAINT_loosen_style branch April 17, 2024 15:41
bsipocz added a commit that referenced this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants