mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 14:06:14 +02:00
Replace flake8 and isort with ruff linter and add black --check
to linting step (#1763)
* Add ruff * Add ruff config * Add ruff rules that look useful and are already passing * Add more ruff rules after talking with Jonathan * Add line length exception for acceptably long indented line * Resolve ruff line length 88 rule in args. Changing small lines but adding a noqa ignore directive to longer lines that look best as they are. Their dedented length is still less than 88 * poe format * Resolve all remaining ruff line length errors * Replace flake* and isort with ruff calls * Add black --check as final lint step. ruff catches most but not all black formatting issues * Remove unneeded flakeheaven setting * Remove flake* and isort now that ruff is handling all their business * Update pyproject, lockfile with latest version of ruff * Document each ruff rule with comment * Add black --version call before black --check * Remove extraneous period
This commit is contained in:
parent
dd09ece4e7
commit
34c7903300
20 changed files with 162 additions and 396 deletions
|
@ -44,13 +44,7 @@ tzlocal = ">=4.0" # https://github.com/regebro/tzlocal/blob/master/CHANGES.txt
|
|||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = { version = ">=21.5b2", allow-prereleases = true }
|
||||
flakeheaven = ">=3.0"
|
||||
flake8-black = ">=0.3.3"
|
||||
flake8-isort = ">=5.0.0"
|
||||
flake8-type-checking = ">=2.2.0"
|
||||
flake8-simplify = ">=0.19"
|
||||
ipdb = "*"
|
||||
isort = ">=5.10"
|
||||
mkdocs = ">=1.4"
|
||||
parse-type = ">=0.6.0"
|
||||
poethepoet = "*"
|
||||
|
@ -59,6 +53,7 @@ pytest-bdd = ">=6.0"
|
|||
pytest-clarity = "*"
|
||||
pytest-xdist = ">=2.5.0"
|
||||
requests = "*"
|
||||
ruff = ">=0.0.276"
|
||||
toml = ">=0.10"
|
||||
tox = "*"
|
||||
xmltodict = "*"
|
||||
|
@ -88,18 +83,18 @@ test-run = [
|
|||
# Groups of tasks
|
||||
format.default_item_type = "cmd"
|
||||
format.sequence = [
|
||||
"isort .",
|
||||
"ruff check . --select I --fix", # equivalent to "isort ."
|
||||
"black .",
|
||||
]
|
||||
|
||||
lint.env = { FLAKEHEAVEN_CACHE_TIMEOUT = "0" }
|
||||
lint.default_item_type = "cmd"
|
||||
lint.sequence = [
|
||||
"poetry --version",
|
||||
"poetry check",
|
||||
"flakeheaven --version",
|
||||
"flakeheaven plugins",
|
||||
"flakeheaven lint",
|
||||
"ruff --version",
|
||||
"ruff .",
|
||||
"black --version",
|
||||
"black --check ."
|
||||
]
|
||||
|
||||
test = [
|
||||
|
@ -107,11 +102,6 @@ test = [
|
|||
"test-run",
|
||||
]
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
force_single_line = true
|
||||
known_first_party = ["jrnl", "tests"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "6.0"
|
||||
required_plugins = [
|
||||
|
@ -137,29 +127,35 @@ filterwarnings = [
|
|||
"ignore:[WinError 5].*"
|
||||
]
|
||||
|
||||
[tool.flakeheaven]
|
||||
max_line_length = 88
|
||||
[tool.ruff]
|
||||
line-length = 88
|
||||
|
||||
# https://beta.ruff.rs/docs/rules/
|
||||
select = [
|
||||
'F', # Pyflakes
|
||||
'E', # pycodestyle errors
|
||||
'W', # pycodestyle warnings
|
||||
'I', # isort
|
||||
'ASYNC', # flake8-async
|
||||
'S110', # try-except-pass
|
||||
'S112', # try-except-continue
|
||||
'EM', # flake8-errmsg
|
||||
'ISC', # flake8-implicit-str-concat
|
||||
'Q', # flake8-quotes
|
||||
'RSE', # flake8-raise
|
||||
'TID', # flake8-tidy-imports
|
||||
'TCH', # flake8-type-checking
|
||||
'T100', # debugger, don't allow break points
|
||||
'ICN' # flake8-import-conventions
|
||||
]
|
||||
exclude = [".git", ".tox", ".venv", "node_modules"]
|
||||
|
||||
[tool.flakeheaven.plugins]
|
||||
"py*" = ["+*"]
|
||||
pycodestyle = [
|
||||
"-E101",
|
||||
"-E111", "-E114", "-E115", "-E116", "-E117",
|
||||
"-E12*",
|
||||
"-E13*",
|
||||
"-E2*",
|
||||
"-E3*",
|
||||
"-E401",
|
||||
"-E5*",
|
||||
"-E70",
|
||||
"-W1*", "-W2*", "-W3*", "-W5*",
|
||||
]
|
||||
"flake8-*" = ["+*"]
|
||||
flake8-black = ["-BLK901"]
|
||||
[tool.ruff.isort]
|
||||
force-single-line = true
|
||||
known-first-party = ["jrnl", "tests"]
|
||||
|
||||
[tool.flakeheaven.exceptions."jrnl/journals/__init__.py"]
|
||||
pyflakes = ["-F401"]
|
||||
[tool.ruff.per-file-ignores]
|
||||
"__init__.py" = ["F401"] # unused imports
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue