Skip to content

Commit

Permalink
style: remove pylint
Browse files Browse the repository at this point in the history
Pylint is pretty much entirely replaced with ruff at this point.
  • Loading branch information
lengau committed May 21, 2024
1 parent 99a0be9 commit a8efd1e
Show file tree
Hide file tree
Showing 46 changed files with 71 additions and 139 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,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
Expand All @@ -58,7 +54,7 @@ test-units: test-legacy-units
tests: tests-static test-units

.PHONY: tests-static
tests-static: test-black test-codespell test-ruff test-isort test-mypy test-pydocstyle test-pyright test-pylint test-shellcheck
tests-static: test-black test-codespell test-ruff test-isort test-mypy test-pydocstyle test-pyright test-shellcheck

.PHONY: lint
lint: tests-static
26 changes: 0 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,6 @@ line_length = 88
skip_gitignore = true
skip = ["tests/spread/tools/snapd-testing-tools"]

[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
Expand Down
3 changes: 0 additions & 3 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,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
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,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",
Expand Down
3 changes: 1 addition & 2 deletions snapcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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()
Expand All @@ -225,7 +224,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
and err.__context__.args[0]
not in dispatcher.commands
):
run_legacy(err)
Expand Down
6 changes: 1 addition & 5 deletions snapcraft/commands/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion snapcraft/commands/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def _validate(self, parsed_args: argparse.Namespace) -> None:
retcode=78, # Configuration error
)

# pylint: disable=too-many-statements
def _run(self, parsed_args: argparse.Namespace, **kwargs: Any) -> int | None:
"""Run the remote-build command.
Expand Down
6 changes: 3 additions & 3 deletions snapcraft/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
snap_channel_map: ChannelMap,
channel_name: str,
architecture: str,
Expand Down Expand Up @@ -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
snap_channel_map,
*,
architectures: Sequence[str],
Expand Down Expand Up @@ -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("")
Expand Down
2 changes: 0 additions & 2 deletions snapcraft/commands/unimplemented.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

from snapcraft import commands, errors

# pylint: disable=missing-class-docstring,unused-argument


class UnimplementedMixin:
"""A mixin that allows you to declare a command unimplemented.
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/commands/validation_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +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
snap_sign = subprocess.Popen(
cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
signed_assertion, _ = snap_sign.communicate(input=json.dumps(assertion).encode())
Expand Down
1 change: 0 additions & 1 deletion snapcraft/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
class SnapArch(str, enum.Enum):
"""An architecture for a snap."""

# pylint: disable=invalid-name
amd64 = "amd64"
arm64 = "arm64"
armhf = "armhf"
Expand Down
4 changes: 0 additions & 4 deletions snapcraft/elf/_elf_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ 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
with self.path.open("rb") as file:
elf_file = elffile.ELFFile(file)
Expand Down Expand Up @@ -318,8 +316,6 @@ def _extract_attributes(self) -> None: # noqa: C901

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()
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/meta/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions snapcraft/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# 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 (
Expand Down Expand Up @@ -933,7 +930,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)
Expand All @@ -946,7 +942,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)
Expand Down Expand Up @@ -1107,7 +1102,7 @@ def get_partitions(self) -> Optional[List[str]]:
return _get_partitions_from_components(self.components)


def _format_pydantic_errors( # pylint: disable=redefined-outer-name
def _format_pydantic_errors(
errors, *, file_name: str = "snapcraft.yaml"
):
"""Format errors.
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/parts/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

# TODO: make checker optional in craft-grammar.
processor = GrammarProcessor(arch=arch, target_arch=target_arch, checker=self_check)
Expand Down
4 changes: 2 additions & 2 deletions snapcraft/parts/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,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
command_name: str,
*,
project: models.Project,
Expand Down Expand Up @@ -440,7 +440,7 @@ 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:
Expand Down
4 changes: 2 additions & 2 deletions snapcraft/parts/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ 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],
Expand Down Expand Up @@ -250,7 +250,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()
Expand Down
10 changes: 5 additions & 5 deletions snapcraft/parts/plugins/_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _get_list_packages_commands(self) -> List[str]:
for ros_build_snap in self._options.colcon_ros_build_snaps: # type: ignore
snap_name = _get_parsed_snap(ros_build_snap)[0]
path = f"/snap/{snap_name}/current/opt/ros"
# pylint: disable=line-too-long

cmd.extend(
[
# Retrieve the list of all ROS packages available in the build snap
Expand All @@ -170,7 +170,7 @@ def _get_list_packages_commands(self) -> List[str]:
"fi",
]
)
# pylint: enable=line-too-long

cmd.append("")

return cmd
Expand Down Expand Up @@ -242,11 +242,11 @@ 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",
Expand Down Expand Up @@ -325,7 +325,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)
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/parts/plugins/kernel_plugin.py
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/parts/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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)

Expand Down
4 changes: 2 additions & 2 deletions snapcraft/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -104,7 +104,7 @@
PROMPT_COMMAND="set_environment; set_prompt"
"""
)
# pylint: enable=line-too-long



def capture_logs_from_instance(instance: executor.Executor) -> None:
Expand Down
4 changes: 2 additions & 2 deletions snapcraft/store/_legacy_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +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
raise errors.LegacyCredentialsParseError(
"Failed to deserialize macaroon"
)

Expand Down Expand Up @@ -160,7 +160,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,
Expand Down
6 changes: 3 additions & 3 deletions snapcraft/store/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def request(self, *args, **kwargs) -> requests.Response:
except craft_store.errors.StoreServerError as store_error:
if (
store_error.response.status_code
== requests.codes.unauthorized # pylint: disable=no-member
== requests.codes.unauthorized
):
if os.getenv(constants.ENVIRONMENT_STORE_CREDENTIALS):
raise errors.StoreCredentialsUnauthorizedError(
Expand Down Expand Up @@ -589,7 +589,7 @@ def release(
self.request(
"POST",
self._base_url
+ self.store_client._endpoints.get_releases_endpoint( # pylint: disable=protected-access
+ self.store_client._endpoints.get_releases_endpoint(
snap_name
),
json=payload,
Expand All @@ -604,7 +604,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
+ self.store_client._endpoints.get_releases_endpoint(
snap_name
),
)
Expand Down
Loading

0 comments on commit a8efd1e

Please sign in to comment.