From 6528b00c46ff4bc5ca577f7d3bf742b79634e079 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 7 Apr 2023 21:00:49 +0200 Subject: [PATCH] chore: Replace flake8 with ruff (#193) --- .flake8 | 6 --- .github/workflows/python_tests.yml | 4 +- pylib/gyp/generator/msvs.py | 2 +- pylib/gyp/generator/ninja.py | 2 +- pylib/gyp/xcodeproj_file.py | 2 +- pyproject.toml | 85 +++++++++++++++++++++++++----- 6 files changed, 75 insertions(+), 26 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 4b052666..00000000 --- a/.flake8 +++ /dev/null @@ -1,6 +0,0 @@ -[flake8] -max-complexity = 101 -max-line-length = 88 -extend-ignore = - # whitespace before ':' to agree with psf/black - E203 diff --git a/.github/workflows/python_tests.yml b/.github/workflows/python_tests.yml index d92c0dc9..6c309363 100644 --- a/.github/workflows/python_tests.yml +++ b/.github/workflows/python_tests.yml @@ -28,10 +28,8 @@ jobs: python -m pip install --upgrade pip setuptools pip install --editable ".[dev]" - run: ./gyp -V && ./gyp --version && gyp -V && gyp --version - - name: Lint with flake8 - run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics - name: Lint with ruff # See pyproject.toml for settings - run: flake8 . + run: ruff --format=github . - name: Test with pytest # See pyproject.toml for settings run: pytest # - name: Run doctests with pytest diff --git a/pylib/gyp/generator/msvs.py b/pylib/gyp/generator/msvs.py index 85c354f7..a98dd9a1 100644 --- a/pylib/gyp/generator/msvs.py +++ b/pylib/gyp/generator/msvs.py @@ -753,7 +753,7 @@ def _EscapeEnvironmentVariableExpansion(s): Returns: The escaped string. - """ # noqa: E731,E123,E501 + """ s = s.replace("%", "%%") return s diff --git a/pylib/gyp/generator/ninja.py b/pylib/gyp/generator/ninja.py index 3644b266..8ba341e9 100644 --- a/pylib/gyp/generator/ninja.py +++ b/pylib/gyp/generator/ninja.py @@ -2530,7 +2530,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name description="SOLINK $lib", restat=True, command=mtime_preserving_solink_base - % {"suffix": "@$link_file_list"}, # noqa: E501 + % {"suffix": "@$link_file_list"}, rspfile="$link_file_list", rspfile_content=( "-Wl,--whole-archive $in $solibs -Wl," "--no-whole-archive $libs" diff --git a/pylib/gyp/xcodeproj_file.py b/pylib/gyp/xcodeproj_file.py index bd56856a..fe7c3dfc 100644 --- a/pylib/gyp/xcodeproj_file.py +++ b/pylib/gyp/xcodeproj_file.py @@ -2769,7 +2769,7 @@ def __init__(self, properties=None, id=None, parent=None, path=None): self.path = path self._other_pbxprojects = {} # super - return XCContainerPortal.__init__(self, properties, id, parent) + XCContainerPortal.__init__(self, properties, id, parent) def Name(self): name = self.path diff --git a/pyproject.toml b/pyproject.toml index 3c48fb74..0e030cd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,21 +37,78 @@ gyp = "gyp:script_main" "Homepage" = "https://github.com/nodejs/gyp-next" [tool.ruff] -line-length = 88 select = [ - "C9", - "E", - "F", - "PLC", - "PLE", - "PLW", - "Q", - "W", - ] - target-version = "py37" - - [tool.ruff.mccabe] - max-complexity = 101 + "C4", # flake8-comprehensions + "C90", # McCabe cyclomatic complexity + "DTZ", # flake8-datetimez + "E", # pycodestyle + "F", # Pyflakes + "G", # flake8-logging-format + "ICN", # flake8-import-conventions + "INT", # flake8-gettext + "PL", # Pylint + "PYI", # flake8-pyi + "RSE", # flake8-raise + "RUF", # Ruff-specific rules + "T10", # flake8-debugger + "TCH", # flake8-type-checking + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # pycodestyle + "YTT", # flake8-2020 + # "A", # flake8-builtins + # "ANN", # flake8-annotations + # "ARG", # flake8-unused-arguments + # "B", # flake8-bugbear + # "BLE", # flake8-blind-except + # "COM", # flake8-commas + # "D", # pydocstyle + # "DJ", # flake8-django + # "EM", # flake8-errmsg + # "ERA", # eradicate + # "EXE", # flake8-executable + # "FBT", # flake8-boolean-trap + # "I", # isort + # "INP", # flake8-no-pep420 + # "ISC", # flake8-implicit-str-concat + # "N", # pep8-naming + # "NPY", # NumPy-specific rules + # "PD", # pandas-vet + # "PGH", # pygrep-hooks + # "PIE", # flake8-pie + # "PT", # flake8-pytest-style + # "PTH", # flake8-use-pathlib + # "Q", # flake8-quotes + # "RET", # flake8-return + # "S", # flake8-bandit + # "SIM", # flake8-simplify + # "SLF", # flake8-self + # "T20", # flake8-print + # "TRY", # tryceratops +] +ignore = [ + "C408", + "C416", + "PLC1901", + "PLR0402", + "PLR2004", + "PLR5501", + "PLW0603", + "PLW2901", + "RUF005", + "UP031", +] +line-length = 88 +target-version = "py37" + +[tool.ruff.mccabe] +max-complexity = 101 + +[tool.ruff.pylint] +max-args = 11 +max-branches = 108 +max-returns = 10 +max-statements = 286 [tool.setuptools] package-dir = {"" = "pylib"}