Merge pull request #12379 from Pierre-Sassoulas/more-pylint-fixes

[pylint] Fix ``consider-using-sys-exit``, ``use-yield-from``, and ``implicit-str-concat``
This commit is contained in:
Pierre Sassoulas 2024-05-29 15:07:04 +02:00 committed by GitHub
commit 0ba3e91fbd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 12 deletions

View File

@ -1,5 +1,6 @@
import json
from pathlib import Path
import sys
import requests
@ -17,7 +18,7 @@ def get_issues():
if r.status_code == 403:
# API request limit exceeded
print(data["message"])
exit(1)
sys.exit(1)
issues.extend(data)
# Look for next page

View File

@ -190,7 +190,6 @@ disable = [
"consider-using-from-import",
"consider-using-f-string",
"consider-using-in",
"consider-using-sys-exit",
"consider-using-ternary",
"consider-using-with",
"cyclic-import",
@ -201,7 +200,6 @@ disable = [
"expression-not-assigned",
"fixme",
"global-statement",
"implicit-str-concat",
"import-error",
"import-outside-toplevel",
"inconsistent-return-statements",
@ -212,10 +210,9 @@ disable = [
"keyword-arg-before-vararg",
"line-too-long",
"method-hidden",
"misplaced-bare-raise",
"missing-docstring",
"missing-timeout",
"multiple-statements",
"multiple-statements", # multiple-statements-on-one-line-colon (E701) from ruff
"no-else-break",
"no-else-continue",
"no-else-raise",

View File

@ -161,15 +161,13 @@ class Visitor:
)
if not self.breadthfirst:
for subdir in dirs:
for p in self.gen(subdir):
yield p
yield from self.gen(subdir)
for p in self.optsort(entries):
if self.fil is None or self.fil(p):
yield p
if self.breadthfirst:
for subdir in dirs:
for p in self.gen(subdir):
yield p
yield from self.gen(subdir)
class FNMatcher:

View File

@ -401,7 +401,7 @@ class LogCaptureHandler(logging_StreamHandler):
# The default behavior of logging is to print "Logging error"
# to stderr with the call stack and some extra details.
# pytest wants to make such mistakes visible during testing.
raise
raise # pylint: disable=misplaced-bare-raise
@final

View File

@ -207,7 +207,7 @@ class CommonFSTests:
@pytest.mark.parametrize(
"fil",
["*dir", "*dir", pytest.mark.skip("sys.version_info <" " (3,6)")(b"*dir")],
["*dir", "*dir", pytest.mark.skip("sys.version_info < (3,6)")(b"*dir")],
)
def test_visit_filterfunc_is_string(self, path1, fil):
lst = []

View File

@ -1163,7 +1163,7 @@ class TestNewFirst:
)
p1.write_text(
"def test_1(): assert 1\n" "def test_2(): assert 1\n", encoding="utf-8"
"def test_1(): assert 1\ndef test_2(): assert 1\n", encoding="utf-8"
)
os.utime(p1, ns=(p1.stat().st_atime_ns, int(1e9)))