From 866caf00fd6a15555b17d7c4e144bea0ccccf770 Mon Sep 17 00:00:00 2001 From: Joris Roovers Date: Mon, 13 Feb 2023 10:50:04 +0000 Subject: Update ruff to 0.0.244 (#442) Fixed or supressed new violations. --- gitlint-core/gitlint/config.py | 2 +- gitlint-core/gitlint/hooks.py | 2 +- gitlint-core/gitlint/rule_finder.py | 2 +- gitlint-core/gitlint/rules.py | 6 +++--- gitlint-core/gitlint/shell.py | 2 +- pyproject.toml | 7 ++++--- qa/base.py | 2 +- qa/shell.py | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gitlint-core/gitlint/config.py b/gitlint-core/gitlint/config.py index 4205ce1..3870caa 100644 --- a/gitlint-core/gitlint/config.py +++ b/gitlint-core/gitlint/config.py @@ -107,7 +107,7 @@ class LintConfig: @handle_option_error def verbosity(self, value): self._verbosity.set(value) - if self.verbosity < 0 or self.verbosity > 3: + if self.verbosity < 0 or self.verbosity > 3: # noqa: PLR2004 (Magic value used in comparison) raise LintConfigError("Option 'verbosity' must be set between 0 and 3") @property diff --git a/gitlint-core/gitlint/hooks.py b/gitlint-core/gitlint/hooks.py index 91756d5..98ded18 100644 --- a/gitlint-core/gitlint/hooks.py +++ b/gitlint-core/gitlint/hooks.py @@ -54,7 +54,7 @@ class GitHookInstaller: with open(dest_path, encoding=FILE_ENCODING) as fp: lines = fp.readlines() - if len(lines) < 2 or lines[1] != GITLINT_HOOK_IDENTIFIER: + if len(lines) < 2 or lines[1] != GITLINT_HOOK_IDENTIFIER: # noqa: PLR2004 (Magic value used in comparison) msg = ( f"The commit-msg hook in {dest_path} was not installed by gitlint (or it was modified).\n" "Uninstallation of 3th party or modified gitlint hooks is not supported." diff --git a/gitlint-core/gitlint/rule_finder.py b/gitlint-core/gitlint/rule_finder.py index db75190..4179c9e 100644 --- a/gitlint-core/gitlint/rule_finder.py +++ b/gitlint-core/gitlint/rule_finder.py @@ -78,7 +78,7 @@ def find_rule_classes(extra_path): return rule_classes -def assert_valid_rule_class(clazz, rule_type="User-defined"): +def assert_valid_rule_class(clazz, rule_type="User-defined"): # noqa: PLR0912 (too many branches) """ Asserts that a given rule clazz is valid by checking a number of its properties: - Rules must extend from LineRule, CommitRule or ConfigurationRule diff --git a/gitlint-core/gitlint/rules.py b/gitlint-core/gitlint/rules.py index e958ab7..492de6d 100644 --- a/gitlint-core/gitlint/rules.py +++ b/gitlint-core/gitlint/rules.py @@ -290,7 +290,7 @@ class BodyMissing(CommitRule): # ignore merges when option tells us to, which may have no body if self.options["ignore-merge-commits"].value and commit.is_merge_commit: return - if len(commit.message.body) < 2 or not "".join(commit.message.body).strip(): + if len(commit.message.body) < 2 or not "".join(commit.message.body).strip(): # noqa: PLR2004 (Magic value) return [RuleViolation(self.id, "Body message is missing", None, 3)] @@ -355,7 +355,7 @@ class AuthorValidEmail(CommitRule): # We're replacing regex match with search semantics, see https://github.com/jorisroovers/gitlint/issues/254 # In case the user is using the default regex, we can silently change to using search # If not, it depends on config (handled by Deprecation class) - if self.DEFAULT_AUTHOR_VALID_EMAIL_REGEX == self.options["regex"].value.pattern: + if self.options["regex"].value.pattern == self.DEFAULT_AUTHOR_VALID_EMAIL_REGEX: regex_method = self.options["regex"].value.search else: regex_method = Deprecation.get_regex_method(self, self.options["regex"]) @@ -443,7 +443,7 @@ class IgnoreBodyLines(ConfigurationRule): new_body.append(line) commit.message.body = new_body - commit.message.full = "\n".join([commit.message.title] + new_body) + commit.message.full = "\n".join([commit.message.title, *new_body]) class IgnoreByAuthorName(ConfigurationRule): diff --git a/gitlint-core/gitlint/shell.py b/gitlint-core/gitlint/shell.py index bab66d6..fddece0 100644 --- a/gitlint-core/gitlint/shell.py +++ b/gitlint-core/gitlint/shell.py @@ -48,7 +48,7 @@ else: Implemented as separate function here, so we can do a 'sh' style imports: `from shell import git` """ - args = ["git"] + list(command_parts) + args = ["git", *list(command_parts)] return _exec(*args, **kwargs) def _exec(*args, **kwargs): diff --git a/pyproject.toml b/pyproject.toml index 8882b6c..cfc6c50 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ dependencies = [ "pytest==7.2.0", "pytest-cov==4.0.0", "python-coveralls==2.9.3", - "ruff==0.0.215", + "ruff==0.0.244", "radon==5.1.0", "pdbr==0.7.5; sys_platform != \"win32\"", ] @@ -164,8 +164,9 @@ extend-exclude = [ ] ignore = [ - "E501", # Never enforce `E501` (line length violations) - taken care of by black - "SIM108", # Use ternary operator instead of if-else-block + "E501", # Never enforce `E501` (line length violations) - taken care of by black + "SIM108", # Use ternary operator instead of if-else-block + "PLR0913", # Too many arguments to function call ] select = [ diff --git a/qa/base.py b/qa/base.py index 92c555f..d8c8c4a 100644 --- a/qa/base.py +++ b/qa/base.py @@ -86,7 +86,7 @@ class BaseTestCase(TestCase): with open(full_path, **open_kwargs) as f: f.write(content) else: - open(full_path, "a", encoding=FILE_ENCODING).close() + open(full_path, "a", encoding=FILE_ENCODING).close() # noqa: SIM115 (Use context handler for opening files) return test_filename diff --git a/qa/shell.py b/qa/shell.py index bbe6dec..3ef874d 100644 --- a/qa/shell.py +++ b/qa/shell.py @@ -75,7 +75,7 @@ else: return run_command("gitlint", *command_parts, **kwargs) def run_command(command, *args, **kwargs): - args = [command] + list(args) + args = [command, *list(args)] return _exec(*args, **kwargs) def _exec(*args, **kwargs): -- cgit v1.2.3