diff --git a/Makefile b/Makefile index 5f88be85ea..5a8eb1b44b 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,6 @@ test-mypy: test-pydocstyle: tox run -e lint-docstyle -.PHONY: test-pylint -test-pylint: - tox run -e lint-pylint - .PHONY: test-pyright test-pyright: tox run -e lint-pyright @@ -53,7 +49,7 @@ test-units: test-legacy-units tests: tests-static test-units .PHONY: tests-static -tests-static: test-black test-codespell test-ruff test-mypy test-pydocstyle test-pyright test-pylint test-shellcheck +tests-static: test-black test-codespell test-ruff test-mypy test-pydocstyle test-pyright test-shellcheck .PHONY: lint lint: tests-static diff --git a/docs/conf.py b/docs/conf.py index 01b33eb7c4..9e456ae914 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,6 +20,7 @@ import sys import craft_parts_docs + import snapcraft project_dir = pathlib.Path("..").resolve() diff --git a/pyproject.toml b/pyproject.toml index b9d7982fa5..2c4fb3c200 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,32 +10,6 @@ extend-exclude = ''' # en masse later. target_version = ["py310", "py311"] -[tool.pylint.main] -ignore-paths = ["tests/legacy"] - -[tool.pylint.messages_control] -# duplicate-code can't be disabled locally: https://github.com/PyCQA/pylint/issues/214 -disable = "too-few-public-methods,fixme,use-implicit-booleaness-not-comparison,duplicate-code,unnecessary-lambda-assignment" - -[tool.pylint.format] -max-attributes = 15 -max-args = 6 -max-locals = 20 -max-branches = 16 -good-names = "id" - -[tool.pylint.MASTER] -extension-pkg-allow-list = [ - "lxml.etree", - "pydantic", - "pytest", - "pygit2", -] -load-plugins = "pylint_fixme_info,pylint_pytest" - -[tool.pylint.SIMILARITIES] -min-similarity-lines=10 - [tool.mypy] python_version = "3.10" ignore_missing_imports = true diff --git a/requirements-devel.txt b/requirements-devel.txt index 5538dd296e..6d44b8de55 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -70,9 +70,6 @@ pyelftools==0.30 pyflakes==3.1.0 pyftpdlib==1.5.9 pygit2==1.13.3 -pylint==2.17.7 -pylint-fixme-info==1.0.3 -pylint-pytest==1.1.7 pylxd==2.3.2 pymacaroons==0.13.0 PyNaCl==1.5.0 diff --git a/setup.py b/setup.py index 850faaec77..c2e9ec633c 100755 --- a/setup.py +++ b/setup.py @@ -73,9 +73,6 @@ def recursive_data_files(directory, install_directory): "pydocstyle", "pyftpdlib", "pyinstaller; sys_platform == 'win32'", - "pylint<3", - "pylint-fixme-info", - "pylint-pytest", "pyramid", "pytest", "pytest-cov", diff --git a/snapcraft/cli.py b/snapcraft/cli.py index 5037f691a5..a5c765fd75 100644 --- a/snapcraft/cli.py +++ b/snapcraft/cli.py @@ -246,7 +246,6 @@ def _emit_error(error, cause=None): emit.error(error) -# pylint: disable-next=too-many-statements def run(): # noqa: C901 (complex-structure) """Run the CLI.""" dispatcher = get_dispatcher() @@ -264,8 +263,7 @@ def run(): # noqa: C901 (complex-structure) with contextlib.suppress(KeyError, IndexError): if ( err.__context__ is not None - and err.__context__.args[0] # pylint: disable=no-member - not in dispatcher.commands + and err.__context__.args[0] not in dispatcher.commands ): run_legacy(err) print(err, file=sys.stderr) # to stderr, as argparse normally does diff --git a/snapcraft/commands/lint.py b/snapcraft/commands/lint.py index af10c441d5..eb3dc81f2c 100644 --- a/snapcraft/commands/lint.py +++ b/snapcraft/commands/lint.py @@ -80,11 +80,7 @@ def fill_parser(self, parser: argparse.ArgumentParser) -> None: help="Set https proxy", ) - def run( # pylint: disable=unused-argument - self, - parsed_args: argparse.Namespace, - **kwargs: Any, - ) -> None: + def run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> None: """Run the linter command. :param parsed_args: snapcraft's argument namespace diff --git a/snapcraft/commands/remote.py b/snapcraft/commands/remote.py index b22fbc4389..f4fe7bf772 100644 --- a/snapcraft/commands/remote.py +++ b/snapcraft/commands/remote.py @@ -162,10 +162,7 @@ def _validate(self, parsed_args: argparse.Namespace) -> None: retcode=78, # Configuration error ) - # pylint: disable=too-many-statements - def _run( # noqa: PLR0915 (Too many statements) - self, parsed_args: argparse.Namespace, **kwargs: Any - ) -> int | None: + def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None: """Run the remote-build command. :param parsed_args: Snapcraft's argument namespace. diff --git a/snapcraft/commands/status.py b/snapcraft/commands/status.py index e581f6172c..12ddae4b48 100644 --- a/snapcraft/commands/status.py +++ b/snapcraft/commands/status.py @@ -183,7 +183,7 @@ def _get_channel_line( ] -def _get_channel_lines_for_channel( # noqa: C901 # pylint: disable=too-many-locals +def _get_channel_lines_for_channel( # noqa: C901 (complex-structure) snap_channel_map: ChannelMap, channel_name: str, architecture: str, @@ -305,7 +305,7 @@ def _has_channels_for_architecture( return found_architecture -def get_tabulated_channel_map( # pylint: disable=too-many-branches, too-many-locals # noqa: C901 +def get_tabulated_channel_map( # noqa: C901 (complex-structure) snap_channel_map, *, architectures: Sequence[str], @@ -353,7 +353,7 @@ def get_tabulated_channel_map( # pylint: disable=too-many-branches, too-many-lo if any(line[expires_column] != "" for line in channel_lines): headers.append("Expires at") for index, _ in enumerate(channel_lines): - if not channel_lines[index][expires_column]: # pylint: disable=R1736 + if not channel_lines[index][expires_column]: channel_lines[index][expires_column] = "-" else: headers.append("") diff --git a/snapcraft/commands/validation_sets.py b/snapcraft/commands/validation_sets.py index 8d6e35fb0c..2f01221dc0 100644 --- a/snapcraft/commands/validation_sets.py +++ b/snapcraft/commands/validation_sets.py @@ -196,9 +196,7 @@ def _sign_assertion(assertion: Dict[str, Any], *, key_name: Optional[str]) -> by cmdline = ["snap", "sign"] if key_name: cmdline += ["-k", key_name] - snap_sign = subprocess.Popen( # pylint: disable=R1732 - cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE - ) + snap_sign = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE) signed_assertion, _ = snap_sign.communicate(input=json.dumps(assertion).encode()) if snap_sign.returncode != 0: raise errors.SnapcraftError("Failed to sign assertion") diff --git a/snapcraft/const.py b/snapcraft/const.py index 4af7ce1ee4..fcf090978a 100644 --- a/snapcraft/const.py +++ b/snapcraft/const.py @@ -22,7 +22,6 @@ class SnapArch(str, enum.Enum): """An architecture for a snap.""" - # pylint: disable=invalid-name amd64 = "amd64" arm64 = "arm64" armhf = "armhf" diff --git a/snapcraft/elf/_elf_file.py b/snapcraft/elf/_elf_file.py index 1f61ff5a7c..17008cb694 100644 --- a/snapcraft/elf/_elf_file.py +++ b/snapcraft/elf/_elf_file.py @@ -232,9 +232,9 @@ def is_elf(cls, path: Path) -> bool: with path.open("rb") as bin_file: return bin_file.read(4) == b"\x7fELF" - # pylint: disable=too-many-branches - - def _extract_attributes(self) -> None: # noqa: C901,PLR0912 + def _extract_attributes( # noqa: PLR0912 (too-many-branches) + self, + ) -> None: with self.path.open("rb") as file: elf_file = elffile.ELFFile(file) @@ -318,8 +318,6 @@ def _extract_attributes(self) -> None: # noqa: C901,PLR0912 self.elf_type = elf_file.header["e_type"] - # pylint: enable=too-many-branches - def is_linker_compatible(self, *, linker_version: str) -> bool: """Determine if the linker will work given the required glibc version.""" version_required = self.get_required_glibc() diff --git a/snapcraft/meta/manifest.py b/snapcraft/meta/manifest.py index 7876e9e2d4..eed2c4b8a7 100644 --- a/snapcraft/meta/manifest.py +++ b/snapcraft/meta/manifest.py @@ -59,7 +59,7 @@ class Manifest(YamlModel): build_snaps: List[str] primed_stage_packages: List - class Config: # pylint: disable=too-few-public-methods + class Config: """Pydantic model configuration.""" allow_population_by_field_name = True diff --git a/snapcraft/models/project.py b/snapcraft/models/project.py index 3bc551eac6..6013a304d7 100644 --- a/snapcraft/models/project.py +++ b/snapcraft/models/project.py @@ -14,12 +14,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# pylint: disable=too-many-lines - """Project file definition and helpers.""" from __future__ import annotations -# pylint: disable=too-many-lines import copy import re from typing import ( @@ -944,7 +941,6 @@ def get_effective_base(self) -> str: def get_build_on(self) -> str: """Get the first build_on architecture from the project for core22.""" - # pylint: disable=unsubscriptable-object if ( self.architectures and isinstance(self.architectures[0], Architecture) @@ -957,7 +953,6 @@ def get_build_on(self) -> str: def get_build_for(self) -> str: """Get the first build_for architecture from the project for core22.""" - # pylint: disable=unsubscriptable-object if ( self.architectures and isinstance(self.architectures[0], Architecture) @@ -1118,9 +1113,7 @@ def get_partitions(self) -> Optional[List[str]]: return _get_partitions_from_components(self.components) -def _format_pydantic_errors( # pylint: disable=redefined-outer-name - errors, *, file_name: str = "snapcraft.yaml" -): +def _format_pydantic_errors(errors, *, file_name: str = "snapcraft.yaml"): """Format errors. Example 1: Single error. diff --git a/snapcraft/parts/grammar.py b/snapcraft/parts/grammar.py index 78efa6ba3a..b7390f9748 100644 --- a/snapcraft/parts/grammar.py +++ b/snapcraft/parts/grammar.py @@ -66,7 +66,7 @@ def process_parts( """ def self_check(value: Any) -> bool: - return value == value # pylint: disable=comparison-with-itself # noqa PLR0124 + return value == value # noqa: PLR0124 (comparison-with-itself) # TODO: make checker optional in craft-grammar. processor = GrammarProcessor(arch=arch, target_arch=target_arch, checker=self_check) diff --git a/snapcraft/parts/lifecycle.py b/snapcraft/parts/lifecycle.py index aef1c73496..b885971bc5 100644 --- a/snapcraft/parts/lifecycle.py +++ b/snapcraft/parts/lifecycle.py @@ -116,7 +116,7 @@ def run(command_name: str, parsed_args: "argparse.Namespace") -> None: ) -def _run_command( # noqa PLR0913 # pylint: disable=too-many-branches, too-many-statements +def _run_command( # noqa PLR0913 (too-many-arguments) command_name: str, *, project: models.Project, @@ -438,7 +438,6 @@ def _clean_provider(project: models.Project, parsed_args: "argparse.Namespace") emit.progress("Cleaned build provider", permanent=True) -# pylint: disable-next=too-many-branches, too-many-statements def _run_in_provider( # noqa PLR0915 project: models.Project, command_name: str, parsed_args: "argparse.Namespace" ) -> None: diff --git a/snapcraft/parts/parts.py b/snapcraft/parts/parts.py index 5b60271678..f27e2a44f9 100644 --- a/snapcraft/parts/parts.py +++ b/snapcraft/parts/parts.py @@ -56,7 +56,6 @@ class PartsLifecycle: :raises PartsLifecycleError: On error initializing the parts lifecycle. """ - # pylint: disable-next=too-many-locals def __init__( # noqa PLR0913 self, all_parts: Dict[str, Any], @@ -250,7 +249,7 @@ def _install_package_repositories(self) -> None: if refresh_required: emit.progress("Refreshing package repositories...") # TODO: craft-parts API for: force_refresh=refresh_required - # pylint: disable=C0415 + from craft_parts.packages import deb deb.Ubuntu.refresh_packages_list.cache_clear() diff --git a/snapcraft/parts/plugins/_ros.py b/snapcraft/parts/plugins/_ros.py index 9897bc2e04..ae47187fa5 100644 --- a/snapcraft/parts/plugins/_ros.py +++ b/snapcraft/parts/plugins/_ros.py @@ -170,7 +170,6 @@ def _get_list_packages_commands(self) -> List[str]: search_path = base_path else: search_path = f"{path_ros_sys}:{path_ros_app}" - # pylint: disable=line-too-long cmd.extend( [ # Retrieve the list of all ROS packages available in the build snap @@ -190,7 +189,7 @@ def _get_list_packages_commands(self) -> List[str]: "fi", ] ) - # pylint: enable=line-too-long + cmd.append("") return cmd @@ -262,11 +261,9 @@ def get_build_commands(self) -> List[str]: # Restore saved state + ['eval "${state}"'] + self._get_list_packages_commands() - # pylint: disable=line-too-long + [ 'rosdep install --default-yes --ignore-packages-from-source --from-paths "${CRAFT_PART_SRC_WORK}"', ] - # pylint: enable=line-too-long + [ 'state="$(set +o); set -$-"', "set +u", @@ -345,7 +342,7 @@ def stage_runtime_dependencies( # noqa: PLR0913 (too many arguments) target_arch: str, stage_cache_dir: str, base: str, -): # pylint: disable=too-many-arguments +): """Stage the runtime dependencies of the ROS stack using rosdep.""" click.echo("Staging runtime dependencies...") # @todo: support python packages (only apt currently supported) diff --git a/snapcraft/parts/plugins/kernel_plugin.py b/snapcraft/parts/plugins/kernel_plugin.py index a158d2784a..3ff7a3a4ba 100644 --- a/snapcraft/parts/plugins/kernel_plugin.py +++ b/snapcraft/parts/plugins/kernel_plugin.py @@ -1,5 +1,5 @@ # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# pylint: disable=line-too-long,too-many-lines,attribute-defined-outside-init + # # Copyright 2020-2022 Canonical Ltd. # diff --git a/snapcraft/parts/yaml_utils.py b/snapcraft/parts/yaml_utils.py index b2f852ab51..42c0a88a5e 100644 --- a/snapcraft/parts/yaml_utils.py +++ b/snapcraft/parts/yaml_utils.py @@ -86,7 +86,7 @@ def _dict_constructor(loader, node): ) from type_error -class _SafeLoader(yaml.SafeLoader): # pylint: disable=too-many-ancestors +class _SafeLoader(yaml.SafeLoader): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/snapcraft/providers.py b/snapcraft/providers.py index a999537a87..ae050a3bf3 100644 --- a/snapcraft/providers.py +++ b/snapcraft/providers.py @@ -47,7 +47,7 @@ } # TODO: move to a package data file for shellcheck and syntax highlighting -# pylint: disable=line-too-long + BASHRC = dedent( """\ #!/bin/bash @@ -104,7 +104,6 @@ PROMPT_COMMAND="set_environment; set_prompt" """ ) -# pylint: enable=line-too-long def capture_logs_from_instance(instance: executor.Executor) -> None: diff --git a/snapcraft/store/_legacy_account.py b/snapcraft/store/_legacy_account.py index 7f877cb84c..4d84b90248 100644 --- a/snapcraft/store/_legacy_account.py +++ b/snapcraft/store/_legacy_account.py @@ -63,9 +63,7 @@ def _deserialize_macaroon(value) -> pymacaroons.Macaroon: try: return pymacaroons.Macaroon.deserialize(value) except: # noqa LP: #1733004 - raise errors.LegacyCredentialsParseError( # pylint: disable=raise-missing-from - "Failed to deserialize macaroon" - ) + raise errors.LegacyCredentialsParseError("Failed to deserialize macaroon") def _get_macaroons_from_conf(conf) -> Dict[str, str]: @@ -160,7 +158,7 @@ def __init__( # noqa PLR0913 base_url: str, storage_base_url: str, auth_url: str, - endpoints: craft_store.endpoints.Endpoints, # pylint: disable=W0621 + endpoints: craft_store.endpoints.Endpoints, application_name: str, user_agent: str, environment_auth: Optional[str] = None, diff --git a/snapcraft/store/client.py b/snapcraft/store/client.py index c61a8e0cff..9774ce7941 100644 --- a/snapcraft/store/client.py +++ b/snapcraft/store/client.py @@ -250,10 +250,7 @@ def request(self, *args, **kwargs) -> requests.Response: try: return self.store_client.request(*args, **kwargs) except craft_store.errors.StoreServerError as store_error: - if ( - store_error.response.status_code - == requests.codes.unauthorized # pylint: disable=no-member - ): + if store_error.response.status_code == requests.codes.unauthorized: if os.getenv(constants.ENVIRONMENT_STORE_CREDENTIALS): raise errors.StoreCredentialsUnauthorizedError( "Exported credentials are no longer valid for the Snap Store.", @@ -589,9 +586,7 @@ def release( self.request( "POST", self._base_url - + self.store_client._endpoints.get_releases_endpoint( # pylint: disable=protected-access - snap_name - ), + + self.store_client._endpoints.get_releases_endpoint(snap_name), json=payload, ) @@ -604,9 +599,7 @@ def get_channel_map(self, *, snap_name: str) -> channel_map.ChannelMap: response = self.request( "GET", self._base_url - + self.store_client._endpoints.get_releases_endpoint( # pylint: disable=protected-access - snap_name - ), + + self.store_client._endpoints.get_releases_endpoint(snap_name), ) return channel_map.ChannelMap.from_list_releases( diff --git a/snapcraft_legacy/internal/repo/apt_sources_manager.py b/snapcraft_legacy/internal/repo/apt_sources_manager.py index 8d979c37c6..ba7ba04c33 100644 --- a/snapcraft_legacy/internal/repo/apt_sources_manager.py +++ b/snapcraft_legacy/internal/repo/apt_sources_manager.py @@ -107,7 +107,7 @@ class AptSourcesManager: :param sources_list_d: Path to sources.list.d directory. """ - # pylint: disable=too-few-public-methods + def __init__( self, *, diff --git a/snapcraft_legacy/plugins/v2/_kernel_build.py b/snapcraft_legacy/plugins/v2/_kernel_build.py index b04e3e0eb1..e1fd3d80c9 100644 --- a/snapcraft_legacy/plugins/v2/_kernel_build.py +++ b/snapcraft_legacy/plugins/v2/_kernel_build.py @@ -1,5 +1,5 @@ # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# pylint: disable=line-too-long,too-many-lines,attribute-defined-outside-init + # # Copyright 2020-2022 Canonical Ltd. # @@ -524,7 +524,7 @@ def _get_perf_build_commands( ] -# pylint: disable-next=too-many-arguments + def _make_initrd_cmd( initrd_compression: Optional[str], initrd_compression_options: Optional[List[str]], @@ -917,7 +917,7 @@ def _make_initrd_cmd( ] -# pylint: disable-next=too-many-arguments + def get_build_commands( make_cmd: List[str], make_targets: List[str], @@ -1142,7 +1142,7 @@ def _compression_cmd( return cmd -# pylint: disable-next=too-many-arguments + def _get_post_install_cmd( device_trees: Optional[List[str]], initrd_compression: Optional[str], @@ -1192,7 +1192,7 @@ def _get_post_install_cmd( ] -# pylint: disable-next=too-many-arguments + def _get_install_command( device_trees: Optional[List[str]], make_cmd: List[str], diff --git a/snapcraft_legacy/plugins/v2/kernel.py b/snapcraft_legacy/plugins/v2/kernel.py index 7077a986fe..59b10c7ed7 100644 --- a/snapcraft_legacy/plugins/v2/kernel.py +++ b/snapcraft_legacy/plugins/v2/kernel.py @@ -1,5 +1,5 @@ # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# pylint: disable=line-too-long,too-many-lines,attribute-defined-outside-init + # # Copyright 2020-2022 Canonical Ltd. # diff --git a/snapcraft_legacy/plugins/v2/rust.py b/snapcraft_legacy/plugins/v2/rust.py index d4c965e268..1d3f51858e 100644 --- a/snapcraft_legacy/plugins/v2/rust.py +++ b/snapcraft_legacy/plugins/v2/rust.py @@ -178,7 +178,7 @@ def get_build_commands(self) -> List[str]: for crate in options.rust_path: logger.info("Generating build commands for %s", crate) config_cmd_string = " ".join(config_cmd) - # pylint: disable=line-too-long + rust_build_cmd_single = dedent( f"""\ if cargo read-manifest --manifest-path "{crate}"/Cargo.toml > /dev/null; then diff --git a/tests/unit/cli/test_version.py b/tests/unit/cli/test_version.py index dd17462429..c6e99ce0e4 100644 --- a/tests/unit/cli/test_version.py +++ b/tests/unit/cli/test_version.py @@ -32,7 +32,7 @@ def test_version_command(mocker): app.run() assert mock_version_cmd.mock_calls == [ call(argparse.Namespace()), - call().__bool__(), # pylint: disable=unnecessary-dunder-call + call().__bool__(), ] diff --git a/tests/unit/commands/test_validation_sets.py b/tests/unit/commands/test_validation_sets.py index b239bd6ca1..f840a27c9f 100644 --- a/tests/unit/commands/test_validation_sets.py +++ b/tests/unit/commands/test_validation_sets.py @@ -254,7 +254,7 @@ def test_edit_validation_sets_with_errors_to_amend( fake_dashboard_post_validation_sets_build_assertion.side_effect = [ StoreValidationSetsError( FakeResponse( - status_code=requests.codes.bad_request, # pylint: disable=no-member + status_code=requests.codes.bad_request, content=json.dumps( {"error_list": [{"message": "bad assertion", "code": "no snap"}]} ).encode(), @@ -310,7 +310,7 @@ def test_edit_validation_sets_with_errors_not_amended( fake_dashboard_post_validation_sets_build_assertion.side_effect = ( StoreValidationSetsError( FakeResponse( - status_code=requests.codes.bad_request, # pylint: disable=no-member + status_code=requests.codes.bad_request, content=json.dumps( {"error_list": [{"message": "bad assertion", "code": "no snap"}]} ).encode(), @@ -352,7 +352,7 @@ def test_edit_yaml_error_retry(mocker, tmp_path, monkeypatch): "{{bad yaml {{", ] - def side_effect(*args, **kwargs): # pylint: disable=unused-argument + def side_effect(*args, **kwargs): tmp_file.write_text(data_write.pop(), encoding="utf-8") subprocess_mock = mocker.patch("subprocess.run", side_effect=side_effect) @@ -368,7 +368,7 @@ def test_edit_yaml_error_no_retry(mocker, tmp_path, monkeypatch): tmp_file = tmp_path / "validation_sets_template" confirm_mock = mocker.patch("snapcraft.utils.confirm_with_user", return_value=False) - def side_effect(*args, **kwargs): # pylint: disable=unused-argument + def side_effect(*args, **kwargs): tmp_file.write_text("{{bad yaml {{", encoding="utf-8") subprocess_mock = mocker.patch("subprocess.run", side_effect=side_effect) diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index f7241c7039..129e7f92b9 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -382,7 +382,6 @@ def extra_project_params(): # The factory setup from CraftApplication is imported at the fixture level. -# pylint: disable=import-outside-toplevel @pytest.fixture() @@ -524,9 +523,6 @@ class FakeRemoteBuildService(RemoteBuild): return service -# pylint: enable=import-outside-toplevel - - @pytest.fixture() def fake_services( default_factory, lifecycle_service, package_service, remote_build_service diff --git a/tests/unit/elf/conftest.py b/tests/unit/elf/conftest.py index aab4dd4a58..fc9e981a18 100644 --- a/tests/unit/elf/conftest.py +++ b/tests/unit/elf/conftest.py @@ -95,7 +95,7 @@ def fake_tools(new_dir, monkeypatch): def _fake_elffile_extract_attributes( # noqa: PLR0915 self, -): # pylint: disable=too-many-statements +): """Mock method definition for ElfFile._extract_attributes().""" name = self.path.name diff --git a/tests/unit/meta/test_appstream.py b/tests/unit/meta/test_appstream.py index ed8bbaaaeb..6bc64bd42b 100644 --- a/tests/unit/meta/test_appstream.py +++ b/tests/unit/meta/test_appstream.py @@ -326,7 +326,7 @@ def test_appstream_with_ol(self): def test_appstream_with_ul_in_p(self): file_name = "snapcraft_legacy.appdata.xml" - # pylint: disable=line-too-long + content = textwrap.dedent( """\ @@ -384,7 +384,6 @@ def test_appstream_with_ul_in_p(self): """ ) - # pylint: enable=line-too-long Path(file_name).write_text(content) @@ -432,7 +431,7 @@ def test_appstream_multilang_title(self): def test_appstream_release(self): file_name = "foliate.appdata.xml" - # pylint: disable=line-too-long + content = textwrap.dedent( """\ @@ -470,7 +469,6 @@ def test_appstream_release(self): """ ) - # pylint: enable=line-too-long Path(file_name).write_text(content) diff --git a/tests/unit/models/test_projects.py b/tests/unit/models/test_projects.py index 72b81626df..8fc3897d2a 100644 --- a/tests/unit/models/test_projects.py +++ b/tests/unit/models/test_projects.py @@ -1554,8 +1554,6 @@ def test_get_snap_project_with_content_plugs_does_not_add_extension( class TestArchitecture: """Validate architectures.""" - # pylint: disable=unsubscriptable-object - def test_architecture_valid_list_of_strings(self, project_yaml_data): """Architectures can be defined as a list of strings (shorthand notation).""" data = project_yaml_data(architectures=["amd64", "armhf"]) diff --git a/tests/unit/parts/plugins/test_colcon.py b/tests/unit/parts/plugins/test_colcon.py index b0c3ec66fc..6cbe004a18 100644 --- a/tests/unit/parts/plugins/test_colcon.py +++ b/tests/unit/parts/plugins/test_colcon.py @@ -167,7 +167,6 @@ def test_out_of_source_build_property(self): def test_get_build_commands_core22( self, setup_method_fixture, new_dir, monkeypatch ): - # pylint: disable=line-too-long plugin = setup_method_fixture("core22", new_dir) monkeypatch.setattr(sys, "path", ["", "/test"]) @@ -325,7 +324,7 @@ def test_get_build_commands_core24( def test_get_build_commands_with_all_properties_core22( self, setup_method_fixture, new_dir, monkeypatch ): - # pylint: disable=line-too-long + plugin = setup_method_fixture( "core22", new_dir, @@ -607,7 +606,7 @@ def test_get_build_commands_with_all_properties_core24( def test_get_build_commands_with_cmake_debug( self, setup_method_fixture, new_dir, monkeypatch ): - # pylint: disable=line-too-long + plugin = setup_method_fixture( "core22", new_dir, diff --git a/tests/unit/parts/plugins/test_kernel.py b/tests/unit/parts/plugins/test_kernel.py index 180676276f..0bc4a68166 100644 --- a/tests/unit/parts/plugins/test_kernel.py +++ b/tests/unit/parts/plugins/test_kernel.py @@ -1909,7 +1909,7 @@ def _is_sub_array(array, sub_array): "ln -f ${CRAFT_PART_BUILD}/.config ${CRAFT_PART_INSTALL}/config-${KERNEL_RELEASE}", ] -# pylint: disable=line-too-long + _finalize_install_cmd = [ textwrap.dedent( """ @@ -1929,7 +1929,7 @@ def _is_sub_array(array, sub_array): """ ) ] -# pylint: enable=line-too-long + _clone_zfs_cmd = [ textwrap.dedent( diff --git a/tests/unit/parts/plugins/test_python_plugin.py b/tests/unit/parts/plugins/test_python_plugin.py index a3061136eb..36487cfcaa 100644 --- a/tests/unit/parts/plugins/test_python_plugin.py +++ b/tests/unit/parts/plugins/test_python_plugin.py @@ -60,7 +60,7 @@ def test_get_build_environment(plugin, new_dir): def test_get_build_commands(plugin, new_dir): - # pylint: disable=line-too-long + assert plugin.get_build_commands() == [ f'"${{PARTS_PYTHON_INTERPRETER}}" -m venv ${{PARTS_PYTHON_VENV_ARGS}} "{new_dir}/parts/my-part/install"', f'PARTS_PYTHON_VENV_INTERP_PATH="{new_dir}/parts/my-part/install/bin/${{PARTS_PYTHON_INTERPRETER}}"', @@ -109,7 +109,6 @@ def test_get_build_commands(plugin, new_dir): ), 'ln -sf "${symlink_target}" "${PARTS_PYTHON_VENV_INTERP_PATH}"\n', ] - # pylint: enable=line-too-long def test_should_remove_symlinks(plugin): diff --git a/tests/unit/parts/test_grammar.py b/tests/unit/parts/test_grammar.py index 6e90a48b01..ff95deef7c 100644 --- a/tests/unit/parts/test_grammar.py +++ b/tests/unit/parts/test_grammar.py @@ -26,7 +26,7 @@ _PROCESSOR = GrammarProcessor( arch="amd64", target_arch="amd64", - checker=lambda x: x == x, # pylint: disable=comparison-with-itself # noqa PLR0124 + checker=lambda x: x == x, # noqa: PLR0124 (comparison-with-itself) ) GrammarEntry = namedtuple("GrammarEntry", ["value", "expected"]) diff --git a/tests/unit/parts/test_lifecycle.py b/tests/unit/parts/test_lifecycle.py index cb4f91f0da..3859cb6fab 100644 --- a/tests/unit/parts/test_lifecycle.py +++ b/tests/unit/parts/test_lifecycle.py @@ -1054,7 +1054,7 @@ def test_lifecycle_shell(snapcraft_yaml, cmd, expected_last_step, new_dir, mocke """Check if the last step executed before shell is the previous step.""" last_step = None - def _fake_execute(_, action: Action, **kwargs): # pylint: disable=unused-argument + def _fake_execute(_, action: Action, **kwargs): nonlocal last_step last_step = action.step @@ -1102,7 +1102,7 @@ def test_lifecycle_shell_after( """Check if the last step executed before shell is the current step.""" last_step = None - def _fake_execute(_, action: Action, **kwargs): # pylint: disable=unused-argument + def _fake_execute(_, action: Action, **kwargs): nonlocal last_step last_step = action.step @@ -1600,7 +1600,6 @@ def test_lifecycle_run_in_provider_default( (EmitterMode.TRACE, "--verbosity=trace"), ], ) -# pylint: disable-next=too-many-locals def test_lifecycle_run_in_provider_all_options( mock_get_instance_name, mock_instance, diff --git a/tests/unit/parts/test_setup_assets.py b/tests/unit/parts/test_setup_assets.py index 3147042e7f..2442f31fa5 100644 --- a/tests/unit/parts/test_setup_assets.py +++ b/tests/unit/parts/test_setup_assets.py @@ -423,7 +423,7 @@ def test_setup_assets_remote_icon(self, desktop_file, yaml_data, new_dir): desktop_file("prime/test.desktop") # define project - # pylint: disable=line-too-long + project = models.Project.unmarshal( yaml_data( { @@ -439,7 +439,6 @@ def test_setup_assets_remote_icon(self, desktop_file, yaml_data, new_dir): }, ) ) - # pylint: enable=line-too-long setup_assets( project, diff --git a/tests/unit/parts/test_setup_assets_components.py b/tests/unit/parts/test_setup_assets_components.py index 1dc091acaa..3024d34efc 100644 --- a/tests/unit/parts/test_setup_assets_components.py +++ b/tests/unit/parts/test_setup_assets_components.py @@ -27,10 +27,7 @@ @pytest.fixture def extra_project_params(extra_project_params): - from craft_application.models import ( # pylint: disable=import-outside-toplevel - SummaryStr, - VersionStr, - ) + from craft_application.models import SummaryStr, VersionStr extra_project_params["components"] = { "firstcomponent": { diff --git a/tests/unit/services/test_lifecycle_components.py b/tests/unit/services/test_lifecycle_components.py index 2d6e42cfdf..8df0327ae1 100644 --- a/tests/unit/services/test_lifecycle_components.py +++ b/tests/unit/services/test_lifecycle_components.py @@ -22,10 +22,7 @@ @pytest.fixture def extra_project_params(extra_project_params): - from craft_application.models import ( # pylint: disable=import-outside-toplevel - SummaryStr, - VersionStr, - ) + from craft_application.models import SummaryStr, VersionStr extra_project_params["components"] = { "firstcomponent": { diff --git a/tests/unit/services/test_package_components.py b/tests/unit/services/test_package_components.py index dee83dab64..90b0daee89 100644 --- a/tests/unit/services/test_package_components.py +++ b/tests/unit/services/test_package_components.py @@ -27,10 +27,7 @@ @pytest.fixture def extra_project_params(extra_project_params): - from craft_application.models import ( # pylint: disable=import-outside-toplevel - SummaryStr, - VersionStr, - ) + from craft_application.models import SummaryStr, VersionStr extra_project_params["components"] = { "firstcomponent": { @@ -104,14 +101,14 @@ def test_pack(package_service, lifecycle_service, mocker): compression="xz", output_dir=Path("."), ), - call().__fspath__(), # pylint: disable=unnecessary-dunder-call + call().__fspath__(), call( lifecycle_service._work_dir / "partitions/component/secondcomponent/prime", compression="xz", output_dir=Path("."), ), - call().__fspath__(), # pylint: disable=unnecessary-dunder-call + call().__fspath__(), ] ) diff --git a/tests/unit/store/test_client.py b/tests/unit/store/test_client.py index dfaff92c8c..359067bf9b 100644 --- a/tests/unit/store/test_client.py +++ b/tests/unit/store/test_client.py @@ -372,7 +372,7 @@ def test_login_otp(fake_client): fake_client.login.side_effect = [ craft_store.errors.StoreServerError( FakeResponse( - status_code=requests.codes.unauthorized, # pylint: disable=no-member + status_code=requests.codes.unauthorized, content=json.dumps( {"error_list": [{"message": "2fa", "code": "twofactor-required"}]} ).encode(), diff --git a/tests/unit/store/utils.py b/tests/unit/store/utils.py index d3fc779e78..3279a90994 100644 --- a/tests/unit/store/utils.py +++ b/tests/unit/store/utils.py @@ -22,7 +22,7 @@ class FakeResponse(requests.Response): """A fake requests.Response.""" - def __init__(self, content, status_code): # pylint: disable=super-init-not-called + def __init__(self, content, status_code): self._content = content self.status_code = status_code diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 1316bfd4a5..5650d2b175 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -648,7 +648,6 @@ def test_confirm_with_user_pause_emitter(mock_isatty, emitter): """The emitter should be paused when using the terminal.""" mock_isatty.return_value = True - # pylint: disable-next=unused-argument def fake_input(prompt): """Check if the Emitter is paused.""" assert emitter.paused diff --git a/tox.ini b/tox.ini index 4e9902c2be..968f36e473 100644 --- a/tox.ini +++ b/tox.ini @@ -9,11 +9,10 @@ # * Additional ruff configuration for snapcraft_legacy # * Do not use tmpfs for a temporary directory as it does not support user xattrs # * Legacy tests (inherited from integration tests) include coverage -# * Pylint included [tox] env_list = # Environments to run when called with no parameters. - lint-{black,ruff,mypy,pylint,pyright,shellcheck,codespell,yaml} + lint-{black,ruff,mypy,pyright,shellcheck,codespell,yaml} test-py310 test-legacy-py310 minversion = 4.5 @@ -107,19 +106,6 @@ commands = codespell: codespell --toml {tox_root}/pyproject.toml {posargs} yaml: yamllint {posargs} . -[testenv:lint-pylint] -description = Lint with pylint -base = testenv -labels = lint -deps = -r{tox_root}/requirements-devel.txt -package = editable -# This runs all commands even if the first fails. -# Not to be confused with ignore_outcome, which turns errors into warnings. -ignore_errors = true -commands = - pylint -j 0 snapcraft - pylint -j 0 tests --disable=invalid-name,missing-module-docstring,missing-function-docstring,duplicate-code,protected-access,unspecified-encoding,too-many-public-methods,too-many-arguments,too-many-lines,redefined-outer-name - [testenv:lint-{mypy,pyright}] description = Static type checking base = testenv