Skip to content

Commit 06323d0

Browse files
authored
Remove pylint (#408)
Ruff replaces pylint
1 parent 56ea296 commit 06323d0

30 files changed

+39
-107
lines changed

.devcontainer/devcontainer.json

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"settings": {
2323
"python.defaultInterpreterPath": "/usr/local/bin/python",
2424
"python.linting.enabled": true,
25-
"python.linting.pylintEnabled": true,
2625
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
2726
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
2827
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
@@ -31,7 +30,6 @@
3130
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
3231
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
3332
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
34-
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
3533
},
3634
// Add the IDs of extensions you want installed when the container is created.
3735
"extensions": [

.github/workflows/checks.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Code formatting (black)
3737
run: hatch run test:format
3838

39-
- name: Code linting (pylint)
39+
- name: Code linting (ruff)
4040
run: hatch run test:lint
4141

4242
- name: Integration tests
@@ -128,7 +128,7 @@ jobs:
128128
- name: Code formatting (black)
129129
run: hatch run test:format
130130

131-
- name: Code linting (pylint)
131+
- name: Code linting (ruff)
132132
run: hatch run test:lint
133133

134134
- name: Integration tests

.pylintrc

-48
This file was deleted.

docs/contributing.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ hatch run qa:integration-tests # Run integration tests
9494
# Formatting check
9595
hatch run test:format # Run formatting checks
9696

97-
# Linting (pylint)
98-
hatch run test:lint # Run pylint
97+
# Linting (ruff)
98+
hatch run test:lint # Run Ruff
9999

100100
# Project stats
101101
hatch run test:stats

gitlint-core/gitlint/cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def _try_cache(self, cache_key, cache_populate_func):
1313
return self._cache[cache_key]
1414

1515

16-
def cache(original_func=None, cachekey=None): # pylint: disable=unused-argument
16+
def cache(original_func=None, cachekey=None):
1717
"""Cache decorator. Caches function return values.
1818
Requires the parent class to extend and initialize PropertyCache.
1919
Usage:

gitlint-core/gitlint/cli.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=bad-option-value,wrong-import-position
21
# We need to disable the import position checks because of the windows check that we need to do below
32
import copy
43
import logging
@@ -72,7 +71,7 @@ def log_system_info():
7271
LOG.debug("DEFAULT_ENCODING: %s", gitlint.utils.DEFAULT_ENCODING)
7372

7473

75-
def build_config( # pylint: disable=too-many-arguments
74+
def build_config(
7675
target,
7776
config_path,
7877
c,
@@ -255,7 +254,7 @@ def __init__(self, config, config_builder, commit_hash, refspec, msg_filename, g
255254
help=f"Config file location [default: {DEFAULT_CONFIG_FILE}]")
256255
@click.option("-c", multiple=True,
257256
help="Config flags in format <rule>.<option>=<value> (e.g.: -c T1.line-length=80). " +
258-
"Flag can be used multiple times to set multiple config values.") # pylint: disable=bad-continuation
257+
"Flag can be used multiple times to set multiple config values.")
259258
@click.option("--commit", envvar="GITLINT_COMMIT", default=None, help="Hash (SHA) of specific commit to lint.")
260259
@click.option("--commits", envvar="GITLINT_COMMITS", default=None,
261260
help="The range of commits (refspec or comma-separated hashes) to lint. [default: HEAD]")
@@ -281,7 +280,7 @@ def __init__(self, config, config_builder, commit_hash, refspec, msg_filename, g
281280
@click.option("-d", "--debug", envvar="GITLINT_DEBUG", help="Enable debugging output.", is_flag=True)
282281
@click.version_option(version=gitlint.__version__)
283282
@click.pass_context
284-
def cli( # pylint: disable=too-many-arguments
283+
def cli(
285284
ctx, target, config, c, commit, commits, extra_path, ignore, contrib,
286285
msg_filename, ignore_stdin, staged, fail_without_commits, verbose,
287286
silent, debug,
@@ -497,5 +496,4 @@ def generate_config(ctx):
497496
# Let's Party!
498497
setup_logging()
499498
if __name__ == "__main__":
500-
# pylint: disable=no-value-for-parameter
501499
cli() # pragma: no cover

gitlint-core/gitlint/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from gitlint import (
1010
options,
1111
rule_finder,
12-
rules, # For some weird reason pylint complains about this, pylint: disable=unused-import
12+
rules,
1313
)
1414
from gitlint.contrib import rules as contrib_rules
1515
from gitlint.exception import GitlintError
@@ -33,7 +33,7 @@ class LintConfigError(GitlintError):
3333
pass
3434

3535

36-
class LintConfig: # pylint: disable=too-many-instance-attributes
36+
class LintConfig:
3737
"""Class representing gitlint configuration.
3838
Contains active config as well as number of methods to easily get/set the config.
3939
"""

gitlint-core/gitlint/display.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ def _output(self, message, verbosity, exact, stream):
1717
if self.config.verbosity >= verbosity:
1818
stream.write(message + "\n")
1919

20-
def v(self, message, exact=False): # pylint: disable=invalid-name
20+
def v(self, message, exact=False):
2121
self._output(message, 1, exact, stdout)
2222

23-
def vv(self, message, exact=False): # pylint: disable=invalid-name
23+
def vv(self, message, exact=False):
2424
self._output(message, 2, exact, stdout)
2525

26-
def vvv(self, message, exact=False): # pylint: disable=invalid-name
26+
def vvv(self, message, exact=False):
2727
self._output(message, 3, exact, stdout)
2828

29-
def e(self, message, exact=False): # pylint: disable=invalid-name
29+
def e(self, message, exact=False):
3030
self._output(message, 1, exact, stderr)
3131

32-
def ee(self, message, exact=False): # pylint: disable=invalid-name
32+
def ee(self, message, exact=False):
3333
self._output(message, 2, exact, stderr)
3434

35-
def eee(self, message, exact=False): # pylint: disable=invalid-name
35+
def eee(self, message, exact=False):
3636
self._output(message, 3, exact, stderr)

gitlint-core/gitlint/git.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _git(*command_parts, **kwargs):
4343
git_kwargs.update(kwargs)
4444
try:
4545
LOG.debug(command_parts)
46-
result = sh.git(*command_parts, **git_kwargs) # pylint: disable=unexpected-keyword-arg
46+
result = sh.git(*command_parts, **git_kwargs)
4747
# If we reach this point and the result has an exit_code that is larger than 0, this means that we didn't
4848
# get an exception (which is the default sh behavior for non-zero exit codes) and so the user is expecting
4949
# a non-zero exit code -> just return the entire result
@@ -77,7 +77,7 @@ def git_commentchar(repository_path=None):
7777
"""Shortcut for retrieving comment char from git config"""
7878
commentchar = _git("config", "--get", "core.commentchar", _cwd=repository_path, _ok_code=[0, 1])
7979
# 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
80-
if hasattr(commentchar, "exit_code") and commentchar.exit_code == 1: # pylint: disable=no-member
80+
if hasattr(commentchar, "exit_code") and commentchar.exit_code == 1:
8181
commentchar = "#"
8282
return commentchar.replace("\n", "")
8383

@@ -190,7 +190,7 @@ def __init__(
190190
message,
191191
sha=None,
192192
date=None,
193-
author_name=None, # pylint: disable=too-many-arguments
193+
author_name=None,
194194
author_email=None,
195195
parents=None,
196196
changed_files_stats=None,
@@ -286,7 +286,7 @@ class LocalGitCommit(GitCommit, PropertyCache):
286286
startup time and reduces gitlint's memory footprint.
287287
"""
288288

289-
def __init__(self, context, sha): # pylint: disable=super-init-not-called
289+
def __init__(self, context, sha):
290290
PropertyCache.__init__(self)
291291
self.context = context
292292
self.sha = sha
@@ -379,7 +379,7 @@ class StagedLocalGitCommit(GitCommit, PropertyCache):
379379
information.
380380
"""
381381

382-
def __init__(self, context, commit_message): # pylint: disable=super-init-not-called
382+
def __init__(self, context, commit_message):
383383
PropertyCache.__init__(self)
384384
self.context = context
385385
self.message = commit_message

gitlint-core/gitlint/lint.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=logging-not-lazy
21
import logging
32

43
from gitlint import display

gitlint-core/gitlint/rule_finder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def find_rule_classes(extra_path):
7878
return rule_classes
7979

8080

81-
def assert_valid_rule_class(clazz, rule_type="User-defined"): # pylint: disable=too-many-branches
81+
def assert_valid_rule_class(clazz, rule_type="User-defined"):
8282
"""
8383
Asserts that a given rule clazz is valid by checking a number of its properties:
8484
- Rules must extend from LineRule, CommitRule or ConfigurationRule

gitlint-core/gitlint/rules.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=inconsistent-return-statements
21
import copy
32
import logging
43
import re

gitlint-core/gitlint/shell.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def shell(cmd):
1717

1818
if USE_SH_LIB:
1919
# import exceptions separately, this makes it a little easier to mock them out in the unit tests
20-
from sh import ( # pylint: disable=import-error
20+
from sh import (
2121
CommandNotFound,
2222
ErrorReturnCode,
23-
git, # pylint: disable=unused-import,import-error
23+
git,
2424
)
2525
else:
2626

gitlint-core/gitlint/tests/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def clearlog(self):
165165
self.logcapture.clear()
166166

167167
@contextlib.contextmanager
168-
def assertRaisesMessage(self, expected_exception, expected_msg): # pylint: disable=invalid-name
168+
def assertRaisesMessage(self, expected_exception, expected_msg):
169169
"""Asserts an exception has occurred with a given error message"""
170170
try:
171171
yield

gitlint-core/gitlint/tests/rules/test_body_rules.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ def test_body_min_length(self):
100100
expected_violation = rules.RuleViolation("B5", "Body message is too short (21<120)", "å" * 21, 3)
101101

102102
rule = rules.BodyMinLength({"min-length": 120})
103-
commit = self.gitcommit("Title\n\n{}\n".format("å" * 21)) # pylint: disable=consider-using-f-string
103+
commit = self.gitcommit("Title\n\n{}\n".format("å" * 21))
104104
violations = rule.validate(commit)
105105
self.assertListEqual(violations, [expected_violation])
106106

107107
# Make sure we don't get the error if the body-length is exactly the min-length
108108
rule = rules.BodyMinLength({"min-length": 8})
109-
commit = self.gitcommit("Tïtle\n\n{}\n".format("å" * 8)) # pylint: disable=consider-using-f-string
109+
commit = self.gitcommit("Tïtle\n\n{}\n".format("å" * 8))
110110
violations = rule.validate(commit)
111111
self.assertIsNone(violations)
112112

gitlint-core/gitlint/tests/rules/test_user_rules.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class MyRuleClass(parent_class):
202202
assert_valid_rule_class(MyRuleClass)
203203

204204
# option_spec is a list, but not of gitlint options
205-
MyRuleClass.options_spec = ["föo", 123] # pylint: disable=bad-option-value,redefined-variable-type
205+
MyRuleClass.options_spec = ["föo", 123]
206206
with self.assertRaisesMessage(UserRuleError, expected_msg):
207207
assert_valid_rule_class(MyRuleClass)
208208

@@ -262,5 +262,5 @@ def validate(self):
262262
assert_valid_rule_class(MyRuleClass)
263263

264264
# valid target, no exception should be raised
265-
MyRuleClass.target = rules.CommitMessageTitle # pylint: disable=bad-option-value,redefined-variable-type
265+
MyRuleClass.target = rules.CommitMessageTitle
266266
self.assertIsNone(assert_valid_rule_class(MyRuleClass))

gitlint-core/gitlint/tests/test_display.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from io import StringIO
2-
from unittest.mock import patch # pylint: disable=no-name-in-module, import-error
2+
from unittest.mock import patch
33

44
from gitlint.config import LintConfig
55
from gitlint.display import Display

gitlint-core/gitlint/tests/test_lint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from io import StringIO
2-
from unittest.mock import patch # pylint: disable=no-name-in-module, import-error
2+
from unittest.mock import patch
33

44
from gitlint.config import LintConfig, LintConfigBuilder
55
from gitlint.lint import GitLinter

gitlint-core/gitlint/utils.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return
21
import codecs
32
import locale
43
import os
@@ -67,7 +66,7 @@ def getpreferredencoding():
6766
# This scenario is fairly common on Windows where git sets LC_CTYPE=C when invoking the commit-msg hook, which
6867
# is not a valid encoding in Python on Windows.
6968
try:
70-
codecs.lookup(default_encoding) # pylint: disable=no-member
69+
codecs.lookup(default_encoding)
7170
except LookupError:
7271
default_encoding = fallback_encoding
7372

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ dependencies = [
8787
"pytest==7.2.0",
8888
"pytest-cov==4.0.0",
8989
"python-coveralls==2.9.3",
90-
"pylint==2.15.3",
9190
"ruff==0.0.215",
9291
"radon==5.1.0",
9392
"pdbr==0.7.5; sys_platform != \"win32\""

qa/base.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return,
2-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
3-
41
import os
52
import platform
63
import shutil
@@ -42,7 +39,7 @@ def tearDown(self):
4239
# On windows we need to ignore errors because git might still be holding on to some files
4340
shutil.rmtree(repo, ignore_errors=PLATFORM_IS_WINDOWS)
4441

45-
def assertEqualStdout(self, output, expected): # pylint: disable=invalid-name
42+
def assertEqualStdout(self, output, expected):
4643
self.assertIsInstance(output, RunningCommand)
4744
output = output.stdout.decode(DEFAULT_ENCODING)
4845
output = output.replace("\r", "")
@@ -86,10 +83,9 @@ def create_file(parent_dir, content=None):
8683
else:
8784
open_kwargs = {"mode": "w", "encoding": FILE_ENCODING}
8885

89-
with open(full_path, **open_kwargs) as f: # pylint: disable=unspecified-encoding
86+
with open(full_path, **open_kwargs) as f:
9087
f.write(content)
9188
else:
92-
# pylint: disable=consider-using-with
9389
open(full_path, "a", encoding=FILE_ENCODING).close()
9490

9591
return test_filename
@@ -152,7 +148,7 @@ def create_tmpfile(self, content):
152148
else:
153149
open_kwargs = {"mode": "w", "encoding": FILE_ENCODING}
154150

155-
with open(tmpfile, **open_kwargs) as f: # pylint: disable=unspecified-encoding
151+
with open(tmpfile, **open_kwargs) as f:
156152
f.write(content)
157153

158154
return tmpfilepath

0 commit comments

Comments
 (0)