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

flake8's (W503 and) W504 #4125

Closed
jamesbraza opened this issue Apr 26, 2023 · 5 comments
Closed

flake8's (W503 and) W504 #4125

jamesbraza opened this issue Apr 26, 2023 · 5 comments
Labels
question Asking for support or clarification

Comments

@jamesbraza
Copy link
Contributor

flake8 has two rules W503 and W504 that don't seem to be in ruff==0.0.263.

Any thoughts on ruff implementing W504 with autofix?

@charliermarsh
Copy link
Member

I think we're unlikely to implement W503 and W504, since we're likely not going to implement the pycodestyle rules that are ignored-by-default (due to being non-unanimously accepted, and non-violations of PEP8, per the pycodestyle docs).

W503 is a little more problematic, since it conflicts with Black. W504 might not conflict with Black, but I'm still hesitant to support it given that it's disabled-by-default in pycodestyle and Flake8.

@charliermarsh charliermarsh added the question Asking for support or clarification label Apr 27, 2023
@charliermarsh
Copy link
Member

(As always, totally open to further discussion -- I just tend to close issues by-default when answering a question, to try and manage the issue queue responsibly.)

@jamesbraza
Copy link
Contributor Author

Oh sure, this conclusion is fine with me, thanks! I realize I have been making a lot of issues here, but it's okay to close them.

For me to remove flake8, I want to make sure the rule coverage is the same. With W504 dispatched (per this issue), the last outstanding items are:

@ccostello97
Copy link

ccostello97 commented Jun 4, 2023

@charliermarsh I'd like to propose this be re-opened. Black does take the stance of W504 against line breaks after binary operators, which also aligns with the PEP-8 recommendation.

To keep my code in check with PEP-8, I have to use ruff with flake8 --select=W504. It would certainly be nice to have this encapsulated in ruff.

@Avasam
Copy link

Avasam commented Mar 4, 2024

FWIW, this would also bring Ruff autofixes closer to parity with autopep8, even if ignored/disabled by default #9057 (comment)

quis added a commit to alphagov/notifications-utils that referenced this issue Dec 6, 2024
ruff doesn’t read `setup.cfg` so the rules defined there are redundant.
This is a hangover from when we used to use `flake8` directly.

I’ve copied some of the rules into pyproject.toml

Selected rules:
- B902 and implemented in ruff as N804 and N805. Only copying N804
  because N805 gets tripped up by sqlalchemy/sqlalchemy#9213
- E203 still in preview in ruff, add a note to include it later

Ignored rules:
- W503 and W504 aren’t likely to be implemented in ruff
  astral-sh/ruff#4125
- E203 is still in preview https://docs.astral.sh/ruff/rules/whitespace-before-punctuation/
  so we don’t need to worry about ignoring it (and maybe it will be fit
  for purpose once it’s out of preview)

Cyclomatic complexity:
- this repo has it set to 8, but everywhere else we use the default (10)
  so let’s not copy that into `pyproject.toml`
quis added a commit to alphagov/notifications-utils that referenced this issue Dec 6, 2024
ruff doesn’t read `setup.cfg` so the rules defined there are redundant.
This is a hangover from when we used to use `flake8` directly.

I’ve copied some of the rules into pyproject.toml

Selected rules:
- B902 and implemented in ruff as N804 and N805. Only copying N804
  because N805 gets tripped up by sqlalchemy/sqlalchemy#9213
- E203 still in preview in ruff, add a note to include it later

Ignored rules:
- W503 and W504 aren’t likely to be implemented in ruff
  astral-sh/ruff#4125
- E203 is still in preview https://docs.astral.sh/ruff/rules/whitespace-before-punctuation/
  so we don’t need to worry about ignoring it (and maybe it will be fit
  for purpose once it’s out of preview)

Cyclomatic complexity:
- this repo has it set to 8, but everywhere else we use the default (10)
  so let’s not copy that into `pyproject.toml`
quis added a commit to alphagov/notifications-utils that referenced this issue Dec 11, 2024
ruff doesn’t read `setup.cfg` so the rules defined there are redundant.
This is a hangover from when we used to use `flake8` directly.

I’ve copied some of the rules into pyproject.toml

Selected rules:
- B902 and implemented in ruff as N804 and N805. Only copying N804
  because N805 gets tripped up by sqlalchemy/sqlalchemy#9213
- E203 still in preview in ruff, add a note to include it later

Ignored rules:
- W503 and W504 aren’t likely to be implemented in ruff
  astral-sh/ruff#4125
- E203 is still in preview https://docs.astral.sh/ruff/rules/whitespace-before-punctuation/
  so we don’t need to worry about ignoring it (and maybe it will be fit
  for purpose once it’s out of preview)

Cyclomatic complexity:
- this repo has it set to 8, but everywhere else we use the default (10)
  so let’s not copy that into `pyproject.toml`
quis added a commit to alphagov/notifications-utils that referenced this issue Dec 11, 2024
ruff doesn’t read `setup.cfg` so the rules defined there are redundant.
This is a hangover from when we used to use `flake8` directly.

I’ve copied some of the rules into pyproject.toml

Selected rules:
- B902 and implemented in ruff as N804 and N805. Only copying N804
  because N805 gets tripped up by sqlalchemy/sqlalchemy#9213
- E203 still in preview in ruff, add a note to include it later

Ignored rules:
- W503 and W504 aren’t likely to be implemented in ruff
  astral-sh/ruff#4125
- E203 is still in preview https://docs.astral.sh/ruff/rules/whitespace-before-punctuation/
  so we don’t need to worry about ignoring it (and maybe it will be fit
  for purpose once it’s out of preview)

Cyclomatic complexity:
- this repo has it set to 8, but everywhere else we use the default (10)
  so let’s not copy that into `pyproject.toml`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

No branches or pull requests

4 participants