Skip to content

chore: Replace flake8 with ruff #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .flake8

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def _EscapeEnvironmentVariableExpansion(s):

Returns:
The escaped string.
""" # noqa: E731,E123,E501
"""
s = s.replace("%", "%%")
return s

Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/generator/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pylib/gyp/xcodeproj_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
85 changes: 71 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down