From e381f6514df554b627049c035f84a689c4a44497 Mon Sep 17 00:00:00 2001 From: Sai Komal Surisetti <143885466+airookie17@users.noreply.github.com> Date: Sat, 5 Oct 2024 17:04:23 +0100 Subject: [PATCH 1/2] [MNT] Move linting to ruff --- .pre-commit-config.yaml | 14 +++++-------- pyproject.toml | 42 +++++++++++++++++++++++++++++++++++--- setup.cfg | 45 ----------------------------------------- 3 files changed, 44 insertions(+), 57 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a5bdce61..e3dc886c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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 diff --git a/pyproject.toml b/pyproject.toml index fbc8bb8f..255acb1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,40 @@ +[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", + "E402", + "E731", + "E741", + "C406", + "C408", + "C409", + "C416", + "C419", + "S101", + "S301", + "S310", + "S101", + "F401", +] + +[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?$' @@ -23,7 +60,7 @@ exclude = ''' ''' [tool.nbqa.mutate] -isort = 1 +ruff = 1 black = 1 [project] @@ -107,10 +144,9 @@ dev = [ # checks and make tools "pre-commit >=3.2.0,<4.0.0", "invoke", - "flake8", "mypy", "pylint", - "isort", + "ruff", # pytest "pytest", "pytest-xdist", diff --git a/setup.cfg b/setup.cfg index 5565b8bc..cb21deb5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 From a9f28339fd5998de5e773f4a6e3249e38f9038da Mon Sep 17 00:00:00 2001 From: Sai Komal Surisetti <143885466+airookie17@users.noreply.github.com> Date: Tue, 8 Oct 2024 23:57:18 +0100 Subject: [PATCH 2/2] [MNT] Move linting to ruff --- pyproject.toml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 255acb1e..5fd42b13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,20 +14,14 @@ exclude = [ [tool.ruff.lint] select = ["E", "F", "W", "C4", "S"] extend-ignore = [ - "E203", - "E402", - "E731", - "E741", - "C406", - "C408", - "C409", - "C416", - "C419", - "S101", - "S301", - "S310", - "S101", - "F401", + "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]