From b5ed4b1136c2b7183d938195dbfb78418391ac75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Fri, 27 Oct 2023 11:49:06 +0200 Subject: [PATCH] Change: Enable pylint rules for ruff Run pylint rules of ruff (error and warning rules) for finding additional issues in our code. --- pontos/github/api/release.py | 2 +- pontos/models/__init__.py | 6 +++--- pontos/version/commands/_java.py | 4 ++-- pyproject.toml | 2 +- tests/version/commands/test_cargo.py | 8 +++----- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pontos/github/api/release.py b/pontos/github/api/release.py index 386ac2cd..4ed9ae3b 100644 --- a/pontos/github/api/release.py +++ b/pontos/github/api/release.py @@ -344,7 +344,7 @@ async def upload_file( tasks = [] for file_path in files: if isinstance(file_path, tuple): - file_path, content_type = file_path + file_path, content_type = file_path # noqa: PLW2901 else: content_type = "application/octet-stream" diff --git a/pontos/models/__init__.py b/pontos/models/__init__.py index 8e5015e4..e2ed1b3a 100644 --- a/pontos/models/__init__.py +++ b/pontos/models/__init__.py @@ -57,7 +57,7 @@ class Foo: if isinstance(value, dict): default = None if hasattr(obj, key) else ModelAttribute() prop = getattr(obj, key, default) - value = dotted_attributes(prop, value) + value = dotted_attributes(prop, value) # noqa: PLW2901 setattr(obj, key, value) @@ -163,10 +163,10 @@ def from_dict(cls, data: Dict[str, Any]): try: if isinstance(value, list): model_field_cls = type_hints.get(name) - value = [cls._get_value(model_field_cls, v) for v in value] # type: ignore # pylint: disable=line-too-long # noqa: E501 + value = [cls._get_value(model_field_cls, v) for v in value] # type: ignore # pylint: disable=line-too-long # noqa: E501,PLW2901 elif value is not None: model_field_cls = type_hints.get(name) - value = cls._get_value(model_field_cls, value) # type: ignore # pylint: disable=line-too-long # noqa: E501 + value = cls._get_value(model_field_cls, value) # type: ignore # pylint: disable=line-too-long # noqa: E501,PLW2901 except (ValueError, TypeError) as e: raise ModelError( f"Error while creating {cls.__name__} model. Could not set " diff --git a/pontos/version/commands/_java.py b/pontos/version/commands/_java.py index 2eb89bd7..bdef4269 100644 --- a/pontos/version/commands/_java.py +++ b/pontos/version/commands/_java.py @@ -18,11 +18,11 @@ import json import re from pathlib import Path -from typing import Literal, Union, Dict, List, Any +from typing import Any, Dict, List, Literal, Union -from ._command import VersionCommand from ..errors import VersionError from ..version import Version, VersionUpdate +from ._command import VersionCommand # This class is used for Java Version command(s) diff --git a/pyproject.toml b/pyproject.toml index 37fc2f4e..d3e6f966 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,7 @@ line_length = 80 [tool.ruff] line-length = 80 target-version = "py39" -extend-select = ["I"] +extend-select = ["I", "PLE", "PLW"] [tool.mypy] files = "pontos" diff --git a/tests/version/commands/test_cargo.py b/tests/version/commands/test_cargo.py index e6c54f01..b13fd6d1 100644 --- a/tests/version/commands/test_cargo.py +++ b/tests/version/commands/test_cargo.py @@ -1,16 +1,14 @@ -from typing import Iterator import unittest - from contextlib import contextmanager from pathlib import Path +from typing import Iterator + import tomlkit from pontos.testing import temp_directory, temp_file from pontos.version import VersionError -from pontos.version.schemes import PEP440VersioningScheme - from pontos.version.commands._cargo import CargoVersionCommand - +from pontos.version.schemes import PEP440VersioningScheme VERSION_EXAMPLE = """ [package]