From 8cb29228a857eba1a2bf259aa5e53735d9e5c3e5 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Sun, 20 Nov 2022 13:26:37 -0500 Subject: [PATCH] Switch to Ruff for linting (#607) --- .flake8 | 11 ----------- hatch.toml | 7 ++----- pyproject.toml | 33 ++++++++++++++++++++++++++++++++- src/hatch/cli/env/show.py | 2 +- 4 files changed, 35 insertions(+), 18 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 3c8096707..000000000 --- a/.flake8 +++ /dev/null @@ -1,11 +0,0 @@ -# TODO: move this to pyproject.toml when supported, see https://github.com/PyCQA/flake8/issues/234 - -[flake8] -select = B,C,E,F,W,B001,B003,B006,B007,B301,B305,B306,B902,Q000,Q001,Q002,Q003,I252 -ignore = B027,E203,E722,W503 -max-line-length = 120 -ban-relative-imports = true -per-file-ignores = - # tests can use relative imports - tests/*: I252 - tests/**/*: I252 diff --git a/hatch.toml b/hatch.toml index eac425245..20de8a499 100644 --- a/hatch.toml +++ b/hatch.toml @@ -49,18 +49,15 @@ detached = true dependencies = [ "bandit>=1.7.4", "black>=22.6.0", - "flake8>=5.0.0", - "flake8-bugbear>=22.10.25", - "flake8-quotes>=3.3.1", - "flake8-tidy-imports>=4.8.0", "isort>=5.10.1", "mypy>=0.990", + "ruff>=0.0.125", ] [envs.lint.scripts] typing = "mypy --install-types --non-interactive {args:backend/src/hatchling src/hatch tests}" security = "bandit --quiet --recursive --skip B101,B102,B105,B110,B112,B301,B307,B324,B403,B404,B603,B604,B606,B607 {args:.}" style = [ - "flake8 {args:.}", + "ruff {args:.}", "black --check --diff {args:.}", "isort --check-only --diff {args:.}", ] diff --git a/pyproject.toml b/pyproject.toml index df10bf6c7..36550b9a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,38 @@ exclude = [ "/scripts", ] -[tool.hatch.build.targets.wheel] +[tool.ruff] +line-length = 120 +select = [ + "B", + "C", + "E", + "F", + "W", + "B003", + "B006", + "B007", + "Q000", + "Q001", + "Q002", + "Q003", + "I252", +] +ignore = [ + "B027", + "C901", +] + +[tool.ruff.flake8-quotes] +inline-quotes = "single" + +[tool.ruff.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.ruff.per-file-ignores] +# tests can use relative imports +"tests/*" = ["I252"] +"tests/**/*" = ["I252"] [tool.mypy] disallow_untyped_defs = false diff --git a/src/hatch/cli/env/show.py b/src/hatch/cli/env/show.py index 3005f9074..e2536c1e4 100644 --- a/src/hatch/cli/env/show.py +++ b/src/hatch/cli/env/show.py @@ -87,7 +87,7 @@ def show(app, envs, force_ascii, as_json): if config.get('features'): if app.project.metadata.hatch.metadata.allow_ambiguous_features: - matrix_columns['Features'][i] = '\n'.join(sorted({f for f in config['features']})) + matrix_columns['Features'][i] = '\n'.join(sorted(set(config['features']))) else: matrix_columns['Features'][i] = '\n'.join( sorted({normalize_project_name(f) for f in config['features']})