Skip to content

Commit

Permalink
[MNT] Move linting to ruff (#1692)
Browse files Browse the repository at this point in the history
### Description

This PR replaces the existing linters `flake8` and `isort` with `ruff`. 

Fixes #1689
  • Loading branch information
airookie17 authored Oct 18, 2024
1 parent 63fadd1 commit dd80041
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 57 deletions.
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-ast
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
- id: ruff
args: [--fix]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
Expand All @@ -24,6 +21,5 @@ repos:
rev: 1.8.7
hooks:
- id: nbqa-black
- id: nbqa-isort
- id: nbqa-flake8
- id: nbqa-ruff
- id: nbqa-check-ast
36 changes: 33 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
[tool.ruff]
line-length = 120
exclude = [
"docs/build/",
"node_modules/",
".eggs/",
"versioneer.py",
"venv/",
".venv/",
".git/",
".history/",
]

[tool.ruff.lint]
select = ["E", "F", "W", "C4", "S"]
extend-ignore = [
"E203", # space before : (needed for how black formats slicing)
"E402", # module level import not at top of file
"E731", # do not assign a lambda expression, use a def
"E741", # ignore not easy to read variables like i l I etc.
"C406", # Unnecessary list literal - rewrite as a dict literal.
"C408", # Unnecessary dict call - rewrite as a literal.
"C409", # Unnecessary list passed to tuple() - rewrite as a tuple literal.
"F401", # unused imports
]

[tool.ruff.lint.isort]
known-first-party = ["pytorch_forecasting"]
combine-as-imports = true
force-sort-within-sections = true

[tool.black]
line-length = 120
include = '\.pyi?$'
Expand All @@ -23,7 +54,7 @@ exclude = '''
'''

[tool.nbqa.mutate]
isort = 1
ruff = 1
black = 1

[project]
Expand Down Expand Up @@ -107,10 +138,9 @@ dev = [
# checks and make tools
"pre-commit >=3.2.0,<4.0.0",
"invoke",
"flake8",
"mypy",
"pylint",
"isort",
"ruff",
# pytest
"pytest",
"pytest-xdist",
Expand Down
45 changes: 0 additions & 45 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
[flake8]
max-line-length = 120
show-source = true
ignore =
# space before : (needed for how black formats slicing)
E203,
# line break before binary operator
W503,
# line break after binary operator
W504,
# module level import not at top of file
E402,
# do not assign a lambda expression, use a def
E731,
# ignore not easy to read variables like i l I etc.
E741,
# Unnecessary list literal - rewrite as a dict literal.
C406,
# Unnecessary dict call - rewrite as a literal.
C408,
# Unnecessary list passed to tuple() - rewrite as a tuple literal.
C409,
# found modulo formatter (incorrect picks up mod operations)
S001,
# unused imports
F401

exclude = docs/build/*.py,
node_modules/*.py,
.eggs/*.py,
versioneer.py,
venv/*,
.venv/*,
.git/*
.history/*

[isort]
profile = black
honor_noqa = true
line_length = 120
combine_as_imports = true
force_sort_within_sections = true
known_first_party = pytorch_forecasting


[coverage:report]
ignore_errors = False
show_missing = true
Expand Down

0 comments on commit dd80041

Please sign in to comment.