diff options
author | Joris Roovers <joris.roovers@gmail.com> | 2023-01-10 13:37:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 13:37:27 +0100 |
commit | 06323d00be298df0bb30a7aa3457d52c9570a954 (patch) | |
tree | be93b101fcda7d40160d4cdff9f8da6d6e3ccc6b | |
parent | 56ea2963b3135a811f9869effdc7009ea43998ed (diff) |
Remove pylint (#408)
Ruff replaces pylint
30 files changed, 39 insertions, 107 deletions
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5889037..fcf85c7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,7 +22,6 @@ "settings": { "python.defaultInterpreterPath": "/usr/local/bin/python", "python.linting.enabled": true, - "python.linting.pylintEnabled": true, "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", "python.formatting.blackPath": "/usr/local/py-utils/bin/black", "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", @@ -31,7 +30,6 @@ "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", - "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 01ac05a..5e21158 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -36,7 +36,7 @@ jobs: - name: Code formatting (black) run: hatch run test:format - - name: Code linting (pylint) + - name: Code linting (ruff) run: hatch run test:lint - name: Integration tests @@ -128,7 +128,7 @@ jobs: - name: Code formatting (black) run: hatch run test:format - - name: Code linting (pylint) + - name: Code linting (ruff) run: hatch run test:lint - name: Integration tests diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index dc54455..0000000 --- a/.pylintrc +++ /dev/null @@ -1,48 +0,0 @@ -# The format of this file isn't really documented; just use --generate-rcfile -[MASTER] - -[Messages Control] -# C0111: Don't require docstrings on every method -# W0511: TODOs in code comments are fine. -# W0142: *args and **kwargs are fine. -# W0223: abstract methods don't need to be overwritten (i.e. when overwriting a Django REST serializer) -# W0622: Redefining id is fine. -# R0901: Too many ancestors (i.e. when subclassing test classes) -# R0801: Similar lines in files -# I0011: Informational: locally disabled pylint -# I0013: Informational: Ignoring entire file -disable=bad-option-value,C0111,W0511,W0142,W0622,W0223,W0212,R0901,R0801,I0011,I0013,anomalous-backslash-in-string,useless-object-inheritance,unnecessary-pass - -[Format] -max-line-length=120 - -[Basic] -# Variable names can be 1 to 31 characters long, with lowercase and underscores -variable-rgx=[a-z_][a-z0-9_]{0,30}$ - -# Argument names can be 2 to 31 characters long, with lowercase and underscores -argument-rgx=[a-z_][a-z0-9_]{1,30}$ - -# Method names should be at least 3 characters long -# and be lower-cased with underscores -method-rgx=([a-z_][a-z0-9_]{2,50}|setUp|tearDown)$ - -# Allow 'id' as variable name everywhere -good-names=id,c,_ - -bad-names=__author__ - -# Ignore all variables that start with an underscore (e.g. unused _request variable in a view) -dummy-variables-rgx=_ - -[Design] -max-public-methods=100 -min-public-methods=0 -# Maximum number of attributes of a class -max-attributes=15 -max-args=10 -max-locals=20 - -[Typecheck] -# Allow the use of the Django 'objects' members -generated-members=sh.git diff --git a/docs/contributing.md b/docs/contributing.md index fd28780..c57fc01 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -94,8 +94,8 @@ hatch run qa:integration-tests # Run integration tests # Formatting check hatch run test:format # Run formatting checks -# Linting (pylint) -hatch run test:lint # Run pylint +# Linting (ruff) +hatch run test:lint # Run Ruff # Project stats hatch run test:stats diff --git a/gitlint-core/gitlint/cache.py b/gitlint-core/gitlint/cache.py index b84c904..a3dd0c8 100644 --- a/gitlint-core/gitlint/cache.py +++ b/gitlint-core/gitlint/cache.py @@ -13,7 +13,7 @@ class PropertyCache: return self._cache[cache_key] -def cache(original_func=None, cachekey=None): # pylint: disable=unused-argument +def cache(original_func=None, cachekey=None): """Cache decorator. Caches function return values. Requires the parent class to extend and initialize PropertyCache. Usage: diff --git a/gitlint-core/gitlint/cli.py b/gitlint-core/gitlint/cli.py index 4433ec3..396885b 100644 --- a/gitlint-core/gitlint/cli.py +++ b/gitlint-core/gitlint/cli.py @@ -1,4 +1,3 @@ -# pylint: disable=bad-option-value,wrong-import-position # We need to disable the import position checks because of the windows check that we need to do below import copy import logging @@ -72,7 +71,7 @@ def log_system_info(): LOG.debug("DEFAULT_ENCODING: %s", gitlint.utils.DEFAULT_ENCODING) -def build_config( # pylint: disable=too-many-arguments +def build_config( target, config_path, c, @@ -255,7 +254,7 @@ class ContextObj: help=f"Config file location [default: {DEFAULT_CONFIG_FILE}]") @click.option("-c", multiple=True, help="Config flags in format <rule>.<option>=<value> (e.g.: -c T1.line-length=80). " + - "Flag can be used multiple times to set multiple config values.") # pylint: disable=bad-continuation + "Flag can be used multiple times to set multiple config values.") @click.option("--commit", envvar="GITLINT_COMMIT", default=None, help="Hash (SHA) of specific commit to lint.") @click.option("--commits", envvar="GITLINT_COMMITS", default=None, help="The range of commits (refspec or comma-separated hashes) to lint. [default: HEAD]") @@ -281,7 +280,7 @@ class ContextObj: @click.option("-d", "--debug", envvar="GITLINT_DEBUG", help="Enable debugging output.", is_flag=True) @click.version_option(version=gitlint.__version__) @click.pass_context -def cli( # pylint: disable=too-many-arguments +def cli( ctx, target, config, c, commit, commits, extra_path, ignore, contrib, msg_filename, ignore_stdin, staged, fail_without_commits, verbose, silent, debug, @@ -497,5 +496,4 @@ def generate_config(ctx): # Let's Party! setup_logging() if __name__ == "__main__": - # pylint: disable=no-value-for-parameter cli() # pragma: no cover diff --git a/gitlint-core/gitlint/config.py b/gitlint-core/gitlint/config.py index f06192e..72f283c 100644 --- a/gitlint-core/gitlint/config.py +++ b/gitlint-core/gitlint/config.py @@ -9,7 +9,7 @@ from configparser import Error as ConfigParserError from gitlint import ( options, rule_finder, - rules, # For some weird reason pylint complains about this, pylint: disable=unused-import + rules, ) from gitlint.contrib import rules as contrib_rules from gitlint.exception import GitlintError @@ -33,7 +33,7 @@ class LintConfigError(GitlintError): pass -class LintConfig: # pylint: disable=too-many-instance-attributes +class LintConfig: """Class representing gitlint configuration. Contains active config as well as number of methods to easily get/set the config. """ diff --git a/gitlint-core/gitlint/display.py b/gitlint-core/gitlint/display.py index 79f010a..1de8d08 100644 --- a/gitlint-core/gitlint/display.py +++ b/gitlint-core/gitlint/display.py @@ -17,20 +17,20 @@ class Display: if self.config.verbosity >= verbosity: stream.write(message + "\n") - def v(self, message, exact=False): # pylint: disable=invalid-name + def v(self, message, exact=False): self._output(message, 1, exact, stdout) - def vv(self, message, exact=False): # pylint: disable=invalid-name + def vv(self, message, exact=False): self._output(message, 2, exact, stdout) - def vvv(self, message, exact=False): # pylint: disable=invalid-name + def vvv(self, message, exact=False): self._output(message, 3, exact, stdout) - def e(self, message, exact=False): # pylint: disable=invalid-name + def e(self, message, exact=False): self._output(message, 1, exact, stderr) - def ee(self, message, exact=False): # pylint: disable=invalid-name + def ee(self, message, exact=False): self._output(message, 2, exact, stderr) - def eee(self, message, exact=False): # pylint: disable=invalid-name + def eee(self, message, exact=False): self._output(message, 3, exact, stderr) diff --git a/gitlint-core/gitlint/git.py b/gitlint-core/gitlint/git.py index 4750171..405d1ab 100644 --- a/gitlint-core/gitlint/git.py +++ b/gitlint-core/gitlint/git.py @@ -43,7 +43,7 @@ def _git(*command_parts, **kwargs): git_kwargs.update(kwargs) try: LOG.debug(command_parts) - result = sh.git(*command_parts, **git_kwargs) # pylint: disable=unexpected-keyword-arg + result = sh.git(*command_parts, **git_kwargs) # If we reach this point and the result has an exit_code that is larger than 0, this means that we didn't # get an exception (which is the default sh behavior for non-zero exit codes) and so the user is expecting # a non-zero exit code -> just return the entire result @@ -77,7 +77,7 @@ def git_commentchar(repository_path=None): """Shortcut for retrieving comment char from git config""" commentchar = _git("config", "--get", "core.commentchar", _cwd=repository_path, _ok_code=[0, 1]) # git will return an exit code of 1 if it can't find a config value, in this case we fall-back to # as commentchar - if hasattr(commentchar, "exit_code") and commentchar.exit_code == 1: # pylint: disable=no-member + if hasattr(commentchar, "exit_code") and commentchar.exit_code == 1: commentchar = "#" return commentchar.replace("\n", "") @@ -190,7 +190,7 @@ class GitCommit: message, sha=None, date=None, - author_name=None, # pylint: disable=too-many-arguments + author_name=None, author_email=None, parents=None, changed_files_stats=None, @@ -286,7 +286,7 @@ class LocalGitCommit(GitCommit, PropertyCache): startup time and reduces gitlint's memory footprint. """ - def __init__(self, context, sha): # pylint: disable=super-init-not-called + def __init__(self, context, sha): PropertyCache.__init__(self) self.context = context self.sha = sha @@ -379,7 +379,7 @@ class StagedLocalGitCommit(GitCommit, PropertyCache): information. """ - def __init__(self, context, commit_message): # pylint: disable=super-init-not-called + def __init__(self, context, commit_message): PropertyCache.__init__(self) self.context = context self.message = commit_message diff --git a/gitlint-core/gitlint/lint.py b/gitlint-core/gitlint/lint.py index c3b7db8..420d3ad 100644 --- a/gitlint-core/gitlint/lint.py +++ b/gitlint-core/gitlint/lint.py @@ -1,4 +1,3 @@ -# pylint: disable=logging-not-lazy import logging from gitlint import display diff --git a/gitlint-core/gitlint/rule_finder.py b/gitlint-core/gitlint/rule_finder.py index fdc9f22..db75190 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"): # pylint: disable=too-many-branches +def assert_valid_rule_class(clazz, rule_type="User-defined"): """ 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 cea4645..e958ab7 100644 --- a/gitlint-core/gitlint/rules.py +++ b/gitlint-core/gitlint/rules.py @@ -1,4 +1,3 @@ -# pylint: disable=inconsistent-return-statements import copy import logging import re diff --git a/gitlint-core/gitlint/shell.py b/gitlint-core/gitlint/shell.py index 21dfaba..a96c517 100644 --- a/gitlint-core/gitlint/shell.py +++ b/gitlint-core/gitlint/shell.py @@ -17,10 +17,10 @@ def shell(cmd): if USE_SH_LIB: # import exceptions separately, this makes it a little easier to mock them out in the unit tests - from sh import ( # pylint: disable=import-error + from sh import ( CommandNotFound, ErrorReturnCode, - git, # pylint: disable=unused-import,import-error + git, ) else: diff --git a/gitlint-core/gitlint/tests/base.py b/gitlint-core/gitlint/tests/base.py index 7c91963..0dbb57b 100644 --- a/gitlint-core/gitlint/tests/base.py +++ b/gitlint-core/gitlint/tests/base.py @@ -165,7 +165,7 @@ class BaseTestCase(unittest.TestCase): self.logcapture.clear() @contextlib.contextmanager - def assertRaisesMessage(self, expected_exception, expected_msg): # pylint: disable=invalid-name + def assertRaisesMessage(self, expected_exception, expected_msg): """Asserts an exception has occurred with a given error message""" try: yield diff --git a/gitlint-core/gitlint/tests/rules/test_body_rules.py b/gitlint-core/gitlint/tests/rules/test_body_rules.py index 1ed4f90..c142e6e 100644 --- a/gitlint-core/gitlint/tests/rules/test_body_rules.py +++ b/gitlint-core/gitlint/tests/rules/test_body_rules.py @@ -100,13 +100,13 @@ class BodyRuleTests(BaseTestCase): expected_violation = rules.RuleViolation("B5", "Body message is too short (21<120)", "å" * 21, 3) rule = rules.BodyMinLength({"min-length": 120}) - commit = self.gitcommit("Title\n\n{}\n".format("å" * 21)) # pylint: disable=consider-using-f-string + commit = self.gitcommit("Title\n\n{}\n".format("å" * 21)) violations = rule.validate(commit) self.assertListEqual(violations, [expected_violation]) # Make sure we don't get the error if the body-length is exactly the min-length rule = rules.BodyMinLength({"min-length": 8}) - commit = self.gitcommit("Tïtle\n\n{}\n".format("å" * 8)) # pylint: disable=consider-using-f-string + commit = self.gitcommit("Tïtle\n\n{}\n".format("å" * 8)) violations = rule.validate(commit) self.assertIsNone(violations) diff --git a/gitlint-core/gitlint/tests/rules/test_user_rules.py b/gitlint-core/gitlint/tests/rules/test_user_rules.py index 6344aef..c2309a6 100644 --- a/gitlint-core/gitlint/tests/rules/test_user_rules.py +++ b/gitlint-core/gitlint/tests/rules/test_user_rules.py @@ -202,7 +202,7 @@ class UserRuleTests(BaseTestCase): assert_valid_rule_class(MyRuleClass) # option_spec is a list, but not of gitlint options - MyRuleClass.options_spec = ["föo", 123] # pylint: disable=bad-option-value,redefined-variable-type + MyRuleClass.options_spec = ["föo", 123] with self.assertRaisesMessage(UserRuleError, expected_msg): assert_valid_rule_class(MyRuleClass) @@ -262,5 +262,5 @@ class UserRuleTests(BaseTestCase): assert_valid_rule_class(MyRuleClass) # valid target, no exception should be raised - MyRuleClass.target = rules.CommitMessageTitle # pylint: disable=bad-option-value,redefined-variable-type + MyRuleClass.target = rules.CommitMessageTitle self.assertIsNone(assert_valid_rule_class(MyRuleClass)) diff --git a/gitlint-core/gitlint/tests/test_display.py b/gitlint-core/gitlint/tests/test_display.py index e655b2c..e669cdb 100644 --- a/gitlint-core/gitlint/tests/test_display.py +++ b/gitlint-core/gitlint/tests/test_display.py @@ -1,5 +1,5 @@ from io import StringIO -from unittest.mock import patch # pylint: disable=no-name-in-module, import-error +from unittest.mock import patch from gitlint.config import LintConfig from gitlint.display import Display diff --git a/gitlint-core/gitlint/tests/test_lint.py b/gitlint-core/gitlint/tests/test_lint.py index eb6e08f..1cf3772 100644 --- a/gitlint-core/gitlint/tests/test_lint.py +++ b/gitlint-core/gitlint/tests/test_lint.py @@ -1,5 +1,5 @@ from io import StringIO -from unittest.mock import patch # pylint: disable=no-name-in-module, import-error +from unittest.mock import patch from gitlint.config import LintConfig, LintConfigBuilder from gitlint.lint import GitLinter diff --git a/gitlint-core/gitlint/utils.py b/gitlint-core/gitlint/utils.py index 20368b7..33b0584 100644 --- a/gitlint-core/gitlint/utils.py +++ b/gitlint-core/gitlint/utils.py @@ -1,4 +1,3 @@ -# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return import codecs import locale import os @@ -67,7 +66,7 @@ def getpreferredencoding(): # This scenario is fairly common on Windows where git sets LC_CTYPE=C when invoking the commit-msg hook, which # is not a valid encoding in Python on Windows. try: - codecs.lookup(default_encoding) # pylint: disable=no-member + codecs.lookup(default_encoding) except LookupError: default_encoding = fallback_encoding diff --git a/pyproject.toml b/pyproject.toml index 3633c53..6c206ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,6 @@ dependencies = [ "pytest==7.2.0", "pytest-cov==4.0.0", "python-coveralls==2.9.3", - "pylint==2.15.3", "ruff==0.0.215", "radon==5.1.0", "pdbr==0.7.5; sys_platform != \"win32\"" @@ -1,6 +1,3 @@ -# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return, -# pylint: disable=too-many-function-args,unexpected-keyword-arg - import os import platform import shutil @@ -42,7 +39,7 @@ class BaseTestCase(TestCase): # On windows we need to ignore errors because git might still be holding on to some files shutil.rmtree(repo, ignore_errors=PLATFORM_IS_WINDOWS) - def assertEqualStdout(self, output, expected): # pylint: disable=invalid-name + def assertEqualStdout(self, output, expected): self.assertIsInstance(output, RunningCommand) output = output.stdout.decode(DEFAULT_ENCODING) output = output.replace("\r", "") @@ -86,10 +83,9 @@ class BaseTestCase(TestCase): else: open_kwargs = {"mode": "w", "encoding": FILE_ENCODING} - with open(full_path, **open_kwargs) as f: # pylint: disable=unspecified-encoding + with open(full_path, **open_kwargs) as f: f.write(content) else: - # pylint: disable=consider-using-with open(full_path, "a", encoding=FILE_ENCODING).close() return test_filename @@ -152,7 +148,7 @@ class BaseTestCase(TestCase): else: open_kwargs = {"mode": "w", "encoding": FILE_ENCODING} - with open(tmpfile, **open_kwargs) as f: # pylint: disable=unspecified-encoding + with open(tmpfile, **open_kwargs) as f: f.write(content) return tmpfilepath diff --git a/qa/shell.py b/qa/shell.py index ac3d57d..1a9472b 100644 --- a/qa/shell.py +++ b/qa/shell.py @@ -6,16 +6,16 @@ import subprocess from qa.utils import DEFAULT_ENCODING, USE_SH_LIB if USE_SH_LIB: - from sh import ( # pylint: disable=unused-import,no-name-in-module,import-error + from sh import ( echo, git, gitlint, ) - gitlint = gitlint.bake(_unify_ttys=True, _tty_in=True) # pylint: disable=invalid-name + gitlint = gitlint.bake(_unify_ttys=True, _tty_in=True) # import exceptions separately, this makes it a little easier to mock them out in the unit tests - from sh import ( # pylint: disable=import-error + from sh import ( CommandNotFound, ErrorReturnCode, RunningCommand, @@ -54,7 +54,7 @@ else: def stderr(self): return self._stderr - def __getattr__(self, p): # pylint: disable=invalid-name + def __getattr__(self, p): # https://github.com/amoffat/sh/blob/e0ed8e244e9d973ef4e0749b2b3c2695e7b5255b/sh.py#L952= _unicode_methods = set(dir(str())) # noqa if p in _unicode_methods: diff --git a/qa/test_commits.py b/qa/test_commits.py index d04a688..ec192e9 100644 --- a/qa/test_commits.py +++ b/qa/test_commits.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-function-args,unexpected-keyword-arg import re import arrow diff --git a/qa/test_config.py b/qa/test_config.py index 1fab792..d051686 100644 --- a/qa/test_config.py +++ b/qa/test_config.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-function-args,unexpected-keyword-arg import os import re diff --git a/qa/test_contrib.py b/qa/test_contrib.py index 6bf86e3..d3a45ba 100644 --- a/qa/test_contrib.py +++ b/qa/test_contrib.py @@ -1,4 +1,3 @@ -# pylint: disable= from qa.base import BaseTestCase from qa.shell import gitlint diff --git a/qa/test_gitlint.py b/qa/test_gitlint.py index 733fb62..45110c0 100644 --- a/qa/test_gitlint.py +++ b/qa/test_gitlint.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-function-args,unexpected-keyword-arg import os from qa.base import BaseTestCase diff --git a/qa/test_hooks.py b/qa/test_hooks.py index 727a2b4..99e76dd 100644 --- a/qa/test_hooks.py +++ b/qa/test_hooks.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-function-args,unexpected-keyword-arg import os from qa.base import BaseTestCase diff --git a/qa/test_stdin.py b/qa/test_stdin.py index 0c98a2c..852349c 100644 --- a/qa/test_stdin.py +++ b/qa/test_stdin.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-function-args,unexpected-keyword-arg import subprocess from qa.base import BaseTestCase diff --git a/qa/test_user_defined.py b/qa/test_user_defined.py index 20fa681..01419cd 100644 --- a/qa/test_user_defined.py +++ b/qa/test_user_defined.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-function-args,unexpected-keyword-arg from qa.base import BaseTestCase from qa.shell import gitlint diff --git a/qa/utils.py b/qa/utils.py index bb730ef..05208bf 100644 --- a/qa/utils.py +++ b/qa/utils.py @@ -1,4 +1,3 @@ -# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return import locale import os import platform |