From db67d5c8749273ebed23788526ad511e342d8b8d Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 27 May 2024 22:18:59 +0200 Subject: [PATCH 1/4] [pylint 'use-yield-from'] Fix all occurences in existing code --- src/_pytest/_py/path.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/_pytest/_py/path.py b/src/_pytest/_py/path.py index bcb05ac34..c7ab1182f 100644 --- a/src/_pytest/_py/path.py +++ b/src/_pytest/_py/path.py @@ -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: From c45afde35d3a81ff27b6ae6c31c515b12d499338 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 27 May 2024 22:34:02 +0200 Subject: [PATCH 2/4] [pylint 'consider-using-sys-exit'] Fix all occurences in existing code --- extra/get_issues.py | 3 ++- pyproject.toml | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/get_issues.py b/extra/get_issues.py index a0c2f19ad..64e859e0c 100644 --- a/extra/get_issues.py +++ b/extra/get_issues.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 11590a90e..4594595e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", From 0d33cdf02a2b742a63be75cbb2309803ea51c525 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 27 May 2024 23:12:29 +0200 Subject: [PATCH 3/4] [pylint] Disable the only 'misplaced-bare-raise' --- pyproject.toml | 3 +-- src/_pytest/logging.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4594595e2..3e01d048e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,10 +211,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", diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index af5e443ce..c9139d369 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -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 From 908e112999c62307c891603bb509cf691ea66f66 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 31 Mar 2024 23:59:08 +0200 Subject: [PATCH 4/4] [pylint 'implicit-str-concat'] fix existing unwanted implicit str concat --- pyproject.toml | 1 - testing/_py/test_local.py | 2 +- testing/test_cacheprovider.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3e01d048e..0627c94c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,7 +200,6 @@ disable = [ "expression-not-assigned", "fixme", "global-statement", - "implicit-str-concat", "import-error", "import-outside-toplevel", "inconsistent-return-statements", diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index ea5794b25..0215aba96 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -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 = [] diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 8728ae84f..08158f619 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -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)))