From 5200a12a2283ce44fe30955640573971057ada29 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Thu, 25 Jul 2024 11:42:38 -0500 Subject: [PATCH] build(deps): use the ruff snap Includes updates for ruff 0.5.4 Signed-off-by: Callahan Kovacs --- HACKING.md | 12 ++++++++++++ snapcraft/commands/remote.py | 6 ++++-- tests/unit/meta/test_appstream.py | 2 +- tox.ini | 4 ++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/HACKING.md b/HACKING.md index a7b33fe922..44622ea88d 100644 --- a/HACKING.md +++ b/HACKING.md @@ -34,6 +34,18 @@ lxc exec snapcraft-dev -- sudo -iu ubuntu bash Import your keys (`ssh-import-id`) and add a `Host` entry to your ssh config if you are interested in [Code's](https://snapcraft.io/code) [Remote-SSH](https://code.visualstudio.com/docs/remote/ssh) plugin. +### Tooling + +We use a large number of tools for our project. Most of these are installed for +you with tox, but you'll need to install: + +- Python 3.10 (default on Ubuntu 22.04, available on Ubuntu 24.04 through the + [deadsnakes](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa) PPA) with setuptools. +- [tox](https://tox.wiki) version 3.8 or later +- [pyright](https://github.com/microsoft/pyright) (also available via snap: `snap install pyright`) +- [ruff](https://github.com/astral/ruff) (also available via snap: `snap install ruff`) +- [ShellCheck](https://www.shellcheck.net/) (also available via snap: `snap install shellcheck`) + ### Testing See the [Testing guide](TESTING.md). diff --git a/snapcraft/commands/remote.py b/snapcraft/commands/remote.py index a5c6d2be8a..4ee6b70261 100644 --- a/snapcraft/commands/remote.py +++ b/snapcraft/commands/remote.py @@ -147,7 +147,9 @@ def _validate(self, parsed_args: argparse.Namespace) -> None: retcode=77, ) - def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: + def _run( # noqa: PLR0915 [too-many-statements] + self, parsed_args: argparse.Namespace, **kwargs: Any + ) -> int | None: """Run the remote-build command. :param parsed_args: Snapcraft's argument namespace. @@ -237,7 +239,7 @@ def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: emit.progress("Cancelling builds.") builder.cancel_builds() returncode = 0 - except Exception: + except Exception: # noqa: BLE001 [blind-except] returncode = 1 # General error on any other exception if returncode != 75: # TimeoutError emit.progress("Cleaning up") diff --git a/tests/unit/meta/test_appstream.py b/tests/unit/meta/test_appstream.py index a7d6bcfc17..788640177c 100644 --- a/tests/unit/meta/test_appstream.py +++ b/tests/unit/meta/test_appstream.py @@ -801,7 +801,7 @@ def test_appstream_with_malformed_links(self): assert metadata.contact == ["rrroschan@gmail.com"] assert metadata.donation == ["https://www.buymeacoffee.com/alainm23"] assert metadata.website == ["https://hello.com"] - assert metadata.source_code == None + assert metadata.source_code is None assert metadata.issues == ["https://github.com/alainm23/planify/issues"] def test_appstream_parse_error(self): diff --git a/tox.ini b/tox.ini index a18d9fe950..bba9fe6575 100644 --- a/tox.ini +++ b/tox.ini @@ -143,8 +143,8 @@ allowlist_externals: ruff: ruff commands = black: black {tty:--color} {posargs} . - ruff: ruff --fix --respect-gitignore setup.py snapcraft tests tools - ruff: ruff --fix --config snapcraft_legacy/ruff.toml snapcraft_legacy tests/legacy + ruff: ruff check --fix --respect-gitignore setup.py snapcraft tests tools + ruff: ruff check --fix --config snapcraft_legacy/ruff.toml snapcraft_legacy tests/legacy codespell: codespell --toml {tox_root}/pyproject.toml --write-changes {posargs} [docs] # Sphinx documentation configuration