-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
I001
conflict with autopep8 / pycodestyle's E302
#3720
Comments
Just trying to make sure I understand -- if I run Ruff over that file, it leaves the import as it is, and |
For me, ruff (0.0.259) formats from typing import TypedDict, type_check_only # Import block is un-sorted or un-formatted Ruff(I001)
@type_check_only
class GCInputs(TypedDict):
pass to from typing import TypedDict, type_check_only
@type_check_only
class GCInputs(TypedDict):
pass Oh, you know what, it's a Also, here's my complete ruff config # https://beta.ruff.rs/docs/configuration
[tool.ruff]
line-length = 120
select = ["ALL"]
target-version = "py38"
# https://beta.ruff.rs/docs/rules
ignore = [
###
# Not needed or wanted
###
"D1", # pydocstyle Missing doctring
"D401", # pydocstyle: non-imperative-mood
"EM", # flake8-errmsg
"FBT", # flake8-boolean-trap
"INP", # flake8-no-pep420
"ISC003", # flake8-implicit-str-concat: explicit-string-concatenation
"TCH002", # flake8-type-checking: typing-only-third-party-import
# Short messages are still considered "long" messages
"TRY003", # tryceratops : raise-vanilla-args
# Don't remove commented code, also too inconsistant
"ERA001", # eradicate: commented-out-code
# contextlib.suppress is roughly 3x slower than try/except
"SIM105", # flake8-simplify: use-contextlib-suppress
# Checked by type-checker (pyright)
"ANN", # flake-annotations
"TCH003", # flake8-type-checking: typing-only-standard-library-import
# We want D213: multi-line-summary-second-line and D211: no-blank-line-before-class
"D203", # pydocstyle: one-blank-line-before-class
"D212", # pydocstyle: multi-line-summary-first-line
]
# https://beta.ruff.rs/docs/settings/#flake8-implicit-str-concat
[tool.ruff.flake8-implicit-str-concat]
allow-multiline = false
# https://beta.ruff.rs/docs/settings/#isort
[tool.ruff.isort]
combine-as-imports = true
required-imports = ["from __future__ import annotations"] # Safer with Python 3.8 and 3.9
split-on-trailing-comma = false
# https://beta.ruff.rs/docs/settings/#mccabe
[tool.ruff.mccabe]
# Hard limit, arbitrary to 4 bytes
max-complexity = 31
# Arbitrary to 2 bytes, same as SonarLint
# max-complexity = 15
[tool.ruff.pylint]
# Arbitrary to 1 byte, same as SonarLint
max-args = 7
# At least same as max-complexity
max-branches = 15
# https://github.com/hhatto/autopep8#usage
# https://github.com/hhatto/autopep8#more-advanced-usage
[tool.autopep8]
aggressive = 3
ignore = [
# TODO Suggest "multi-line method invocation style" to Ruff.
# https://github.com/charliermarsh/ruff/issues/3713
"E124", # Closing bracket may not match multi-line method invocation style (enforced by add-trailing-comma)
"E402", # Allow imports at the bottom of file
"E70", # Allow ... on same line as def
"W503", # Linebreak before binary operator
]
max_line_length = 120
recursive = true |
Ahhh yes the rules are slightly different for |
Yeah not sure what we can do here. Black reformats |
Not sure either (other than allowing to disable |
That is the standard for |
Yeah unfortunately I think this has to be marked as wontfix. I understand the inconvenience but it's tough to retain compatibility when the tools conflict. |
Thanks for your understanding and for bearing with me as we talked through this :) |
See this minimal reproduction:
Ref: https://peps.python.org/pep-0008/#blank-lines and https://pycodestyle.pycqa.org/en/latest/intro.html?highlight=E302#error-codes
I001
wants 1 line,E302
wants 2.I use the default lines-after-imports (so it should be -1)
Is there a way to ignore just
lines-after-imports
without ignoring the entirety of I001 ?I'd like to either let the non-ruff formatter take care of it. Or have Ruff implement
E302
(#2402) so it's aware of it when linting imports.Temporary workaround, add a dangling
#
. May as well link to this issue while I'm at it:The text was updated successfully, but these errors were encountered: