Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: remove pylint #4817

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import sys

import craft_parts_docs

import snapcraft

project_dir = pathlib.Path("..").resolve()
Expand Down
26 changes: 0 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions snapcraft/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
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
5 changes: 1 addition & 4 deletions snapcraft/commands/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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 (complex-structure)
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 (complex-structure)
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
4 changes: 1 addition & 3 deletions snapcraft/commands/validation_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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
8 changes: 3 additions & 5 deletions snapcraft/elf/_elf_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
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
9 changes: 1 addition & 8 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 @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.
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 # noqa: PLR0124 (comparison-with-itself)

# TODO: make checker optional in craft-grammar.
processor = GrammarProcessor(arch=arch, target_arch=target_arch, checker=self_check)
Expand Down
3 changes: 1 addition & 2 deletions snapcraft/parts/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions snapcraft/parts/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 2 additions & 5 deletions snapcraft/parts/plugins/_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -190,7 +189,7 @@ def _get_list_packages_commands(self) -> List[str]:
"fi",
]
)
# pylint: enable=line-too-long

cmd.append("")

return cmd
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
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 @@ -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)

Expand Down
3 changes: 1 addition & 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,6 @@
PROMPT_COMMAND="set_environment; set_prompt"
"""
)
# pylint: enable=line-too-long


def capture_logs_from_instance(instance: executor.Executor) -> None:
Expand Down
6 changes: 2 additions & 4 deletions snapcraft/store/_legacy_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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,
Expand Down
Loading
Loading