From 9c2923932c6b3dbb0869052d763dee8fb8ad5d3e Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Thu, 29 Aug 2024 08:10:31 -0400 Subject: [PATCH] Add Pylint support and enable Pylint CI checks --- .github/workflows/pylint.yaml | 22 +++++++++ archinstall/lib/interactions/general_conf.py | 4 +- archinstall/lib/models/users.py | 2 +- archinstall/lib/packages/packages.py | 2 +- pyproject.toml | 49 ++++++++++++++++++++ 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/pylint.yaml diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml new file mode 100644 index 0000000000..23dfa0132a --- /dev/null +++ b/.github/workflows/pylint.yaml @@ -0,0 +1,22 @@ +on: [ push, pull_request ] +name: Pylint linting +jobs: + pylint: + runs-on: ubuntu-latest + container: + image: archlinux/archlinux:latest + steps: + - uses: actions/checkout@v4 + - name: Prepare arch + run: | + pacman-key --init + pacman --noconfirm -Sy archlinux-keyring + pacman --noconfirm -Syyu + pacman --noconfirm -Sy python-pip python-pyparted python-simple-term-menu pkgconfig gcc + - run: pip install --break-system-packages --upgrade pip + - name: Install Pylint and Pylint plug-ins + run: pip install --break-system-packages .[dev] + - run: python --version + - run: pylint --version + - name: Lint with Pylint + run: pylint . diff --git a/archinstall/lib/interactions/general_conf.py b/archinstall/lib/interactions/general_conf.py index 893f10f26c..bd3e78446d 100644 --- a/archinstall/lib/interactions/general_conf.py +++ b/archinstall/lib/interactions/general_conf.py @@ -61,8 +61,8 @@ def ask_for_audio_selection( current: Optional[AudioConfiguration] = None ) -> Optional[AudioConfiguration]: choices = [ - Audio.Pipewire.name, - Audio.Pulseaudio.name, + Audio.Pipewire.name, # pylint: disable=no-member + Audio.Pulseaudio.name, # pylint: disable=no-member Audio.no_audio_text() ] diff --git a/archinstall/lib/models/users.py b/archinstall/lib/models/users.py index 045d9d61e9..67e4a8801c 100644 --- a/archinstall/lib/models/users.py +++ b/archinstall/lib/models/users.py @@ -13,7 +13,7 @@ class PasswordStrength(Enum): STRONG = 'strong' @property - def value(self) -> str: + def value(self) -> str: # pylint: disable=invalid-overridden-method match self: case PasswordStrength.VERY_WEAK: return str(_('very weak')) case PasswordStrength.WEAK: return str(_('weak')) diff --git a/archinstall/lib/packages/packages.py b/archinstall/lib/packages/packages.py index f7f1e8179e..10d62d9963 100644 --- a/archinstall/lib/packages/packages.py +++ b/archinstall/lib/packages/packages.py @@ -113,4 +113,4 @@ def installed_package(package: str) -> LocalPackage: except SysCallError: pass - return LocalPackage({field.name: package_info.get(field.name) for field in dataclasses.fields(LocalPackage)}) # type: ignore + return LocalPackage({field.name: package_info.get(field.name) for field in dataclasses.fields(LocalPackage)}) # type: ignore # pylint: disable=no-value-for-parameter diff --git a/pyproject.toml b/pyproject.toml index 7feb07aa8d..b42ed55a91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,8 @@ dev = [ "flake8==7.1.1", "pre-commit==4.0.1", "ruff==0.7.0", + "pylint==3.3.1", + "pylint-pydantic==0.3.2", ] doc = ["sphinx"] @@ -120,6 +122,53 @@ ignore_missing_imports = true targets = ["archinstall"] exclude = ["/tests"] +[tool.pylint.main] +ignore-paths = [ + "^build/", + "^docs/", +] +load-plugins = ["pylint_pydantic"] +persistent = false +py-version = "3.11" +recursive = true + +[tool.pylint.format] +max-line-length = 220 + +[tool.pylint."messages control"] +disable = [ + "C", + "R", + "arguments-renamed", + "attribute-defined-outside-init", + "bad-indentation", + "bare-except", + "broad-exception-caught", + "cell-var-from-loop", + "comparison-with-callable", + "dangerous-default-value", + "expression-not-assigned", + "f-string-without-interpolation", + "fixme", + "protected-access", + "raise-missing-from", + "redefined-builtin", + "redefined-outer-name", + "self-assigning-variable", + "unnecessary-lambda", + "unreachable", + "unspecified-encoding", + "unused-argument", + "unused-variable", + "useless-parent-delegation", +] + +[tool.pylint.refactoring] +score = false + +[tool.pylint.variables] +additional-builtins = ["_"] + [tool.ruff] target-version = "py311" builtins = ["_"]