From 3d5bcde5ea541f1b10dafaf44eb267cc1c112948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Tue, 25 Feb 2025 11:44:59 +0100 Subject: [PATCH 1/2] Sort and format ruff selections --- pyproject.toml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 849fcceb..7f9bf1b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,14 +118,14 @@ src = ["src"] line-length = 88 [tool.ruff.lint] select = [ - "W", # pycodestyle - "I", # isort - "B", # flake-8-bugbear - "SIM", # flake-8-simplify - "F", # pyflakes - "UP", # pyupgrade - "PERF", # perflint - "C4", # flake8-comprehensions + "B", # flake-8-bugbear + "C4", # flake8-comprehensions + "F", # pyflakes + "I", # isort + "PERF", # perflint + "SIM", # flake-8-simplify + "UP", # pyupgrade + "W", # pycodestyle ] ignore = ["PERF203"] From 135d2b6c23f3d54d10846f3617273606ffa140e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Tue, 25 Feb 2025 12:08:16 +0100 Subject: [PATCH 2/2] Switch from pylint to ruff Not all exceptions that was needed for pylint is needed for ruff, meaning they are not identical in their linting, but ruff is so much faster we will let it decide. --- .github/workflows/style.yml | 10 ++---- komodo/build.py | 4 +-- komodo/lint.py | 2 +- komodo/lint_upgrade_proposals.py | 1 - komodo/matrix.py | 2 +- komodo/pypi_dependencies.py | 1 - pyproject.toml | 58 +++++++++----------------------- tests/test_up_to_date_pypi.py | 1 - 8 files changed, 23 insertions(+), 56 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 30d3c16a..570e9067 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -31,12 +31,8 @@ jobs: - name: Lint with ruff run: | - ruff check komodo tests + ruff check . - - name: Format with ruff + - name: Verify formatting with ruff run: | - ruff format komodo tests --check - - - name: pylint - run: | - pylint komodo tests + ruff format --diff . diff --git a/komodo/build.py b/komodo/build.py index 1b9af1b3..94bc6dcb 100644 --- a/komodo/build.py +++ b/komodo/build.py @@ -52,7 +52,7 @@ def cmake( Path(bdir).mkdir(parents=True, exist_ok=True) with pushd(bdir): os.environ["LD_LIBRARY_PATH"] = ld_lib_path - _pre_PATH = os.environ["PATH"] # pylint: disable=invalid-name + _pre_PATH = os.environ["PATH"] os.environ["PATH"] = bin_path print(f"Installing {package_name} ({ver}) from source with cmake") @@ -79,7 +79,7 @@ def sh( jobs=None, cmake=None, makeopts=None, -): # pylint: disable=invalid-name +): makefile = data.get(makefile) with pushd(pkgpath): diff --git a/komodo/lint.py b/komodo/lint.py index e5e4c257..be011473 100755 --- a/komodo/lint.py +++ b/komodo/lint.py @@ -53,7 +53,7 @@ def lint_version_numbers(package, version, repo): parsed_version ): # don't know if possible to check otherwise return KomodoError(package, version, maintainer) - except Exception as err: # pylint: disable=broad-exception-caught + except Exception as err: # Log any exception: return KomodoError(package, version, maintainer, err=str(err)) return None diff --git a/komodo/lint_upgrade_proposals.py b/komodo/lint_upgrade_proposals.py index d659629f..cd404fb8 100644 --- a/komodo/lint_upgrade_proposals.py +++ b/komodo/lint_upgrade_proposals.py @@ -22,7 +22,6 @@ def extract_versions(nested_package_version) -> list: package_versions = [] if isinstance(nested_package_version, dict): for nested_packages in nested_package_version.values(): - # pylint: disable=cell-var-from-loop package_versions.extend(extract_versions(nested_packages)) else: package_versions.append(nested_package_version) diff --git a/komodo/matrix.py b/komodo/matrix.py index 804949fa..58759a60 100644 --- a/komodo/matrix.py +++ b/komodo/matrix.py @@ -23,7 +23,7 @@ def get_matrix( if custom_coordinate: if len(custom_coordinate) != 1: raise ValueError("custom_coordinate must contain exactly one item") - component_name, component_seq = next(iter(custom_coordinate.items())) # pylint: disable=stop-iteration-return + component_name, component_seq = next(iter(custom_coordinate.items())) for product in itertools.product(rhel_versions, py_versions, component_seq): rh_ver, py_ver, other_ver = product diff --git a/komodo/pypi_dependencies.py b/komodo/pypi_dependencies.py index 788df4e2..8afa9c63 100644 --- a/komodo/pypi_dependencies.py +++ b/komodo/pypi_dependencies.py @@ -52,7 +52,6 @@ def version_list_to_requirements( ] -# pylint: disable=too-many-instance-attributes class PypiDependencies: def __init__( self, diff --git a/pyproject.toml b/pyproject.toml index 7f9bf1b0..598fde6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,6 @@ dependencies = [ dev = [ "furo", "myst_parser", - "pylint", "pytest", "ruff", "sphinx", @@ -74,45 +73,6 @@ komodo-suggest-symlinks = "komodo.symlink.suggester.cli:main" komodo-transpiler = "komodo.release_transpiler:main" komodo-check-unused = "komodo.check_unused_package:main" -[tool.pylint.messages_control] -disable = [ - "bad-inline-option", - "consider-using-sys-exit", - "deprecated-pragma", - "duplicate-code", - "file-ignored", - "fixme", - "line-too-long", - "locally-disabled", - "logging-not-lazy", - "logging-fstring-interpolation", # Do not remove; it greatly decreases readability - "missing-class-docstring", - "missing-function-docstring", - "missing-module-docstring", - "no-else-return", - "protected-access", - "raise-missing-from", - "raw-checker-failed", - "redefined-outer-name", - "suppressed-message", - "too-few-public-methods", - "too-many-arguments", - "too-many-branches", - "too-many-locals", - "too-many-statements", - "use-a-generator", - "use-implicit-booleaness-not-comparison", - "use-symbolic-message-instead", - "useless-object-inheritance", - "too-many-lines", - "too-many-positional-arguments", -] - -[tool.pylint.MASTER] -ignore-paths = [ - '^.*\\_version.py' -] - [tool.ruff] src = ["src"] line-length = 88 @@ -123,12 +83,26 @@ select = [ "F", # pyflakes "I", # isort "PERF", # perflint + "PL", # pylint "SIM", # flake-8-simplify "UP", # pyupgrade "W", # pycodestyle ] - -ignore = ["PERF203"] +ignore = [ + "PERF203", # try-except-in-loop + "PLR0912", # Too many branches + "PLR0913", # too-many-arguments + "PLR0915", # Too many statements + "PLR1722", # use sys.exit + "PLR2004", # Magic value used in comparison + "PLR5501", # use elif instead of else then if + "PLW2901", # for loop variable overwritten +] [tool.ruff.lint.isort] known-first-party = ["komodo"] + +[tool.ruff.lint.extend-per-file-ignores] +"docs/conf.py" = [ + "PLR1711", # useless return statement +] diff --git a/tests/test_up_to_date_pypi.py b/tests/test_up_to_date_pypi.py index 95ca8c5e..4af0426b 100644 --- a/tests/test_up_to_date_pypi.py +++ b/tests/test_up_to_date_pypi.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines import functools import os import pathlib