Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pylint] Fixes all use-maxplit-args, consider-using-enumerate #12172

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,20 @@ disable = [
"bad-mcs-method-argument",
"broad-exception-caught",
"broad-exception-raised",
"cell-var-from-loop",
"cell-var-from-loop", # B023 from ruff / flake8-bugbear
"comparison-of-constants",
"comparison-with-callable",
"comparison-with-itself",
"condition-evals-to-constant",
"consider-using-dict-items",
"consider-using-enumerate",
"consider-using-from-import",
"consider-using-f-string",
"consider-using-in",
"consider-using-sys-exit",
"consider-using-ternary",
"consider-using-with",
"cyclic-import",
"disallowed-name",
"disallowed-name", # foo / bar are used often in tests
"duplicate-code",
"eval-used",
"exec-used",
Expand Down Expand Up @@ -229,6 +228,7 @@ disable = [
"pointless-exception-statement",
"pointless-statement",
"pointless-string-statement",
"possibly-used-before-assignment",
"protected-access",
"raise-missing-from",
"redefined-argument-from-local",
Expand Down Expand Up @@ -276,7 +276,6 @@ disable = [
"useless-else-on-loop",
"useless-import-alias",
"useless-return",
"use-maxsplit-arg",
"using-constant-test",
"wrong-import-order",
]
Expand Down
9 changes: 7 additions & 2 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,10 @@
fixture_doc = inspect.getdoc(fixture_def.func)
if fixture_doc:
write_docstring(
tw, fixture_doc.split("\n\n")[0] if verbose <= 0 else fixture_doc
tw,
fixture_doc.split("\n\n", maxsplit=1)[0]
if verbose <= 0
else fixture_doc,
)
else:
tw.line(" no docstring available", red=True)
Expand Down Expand Up @@ -1903,7 +1906,9 @@
tw.write("\n")
doc = inspect.getdoc(fixturedef.func)
if doc:
write_docstring(tw, doc.split("\n\n")[0] if verbose <= 0 else doc)
write_docstring(

Check warning on line 1909 in src/_pytest/fixtures.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/fixtures.py#L1909

Added line #L1909 was not covered by tests
tw, doc.split("\n\n", maxsplit=1)[0] if verbose <= 0 else doc
)
else:
tw.line(" no docstring available", red=True)
tw.line()
Expand Down
12 changes: 6 additions & 6 deletions testing/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def test_repr_entry():

rep_entries = rep.longrepr.reprtraceback.reprentries
a_entries = a.longrepr.reprtraceback.reprentries
for i in range(len(a_entries)):
rep_entry = rep_entries[i]
assert len(rep_entries) == len(a_entries) # python < 3.10 zip(strict=True)
for a_entry, rep_entry in zip(a_entries, rep_entries):
assert isinstance(rep_entry, ReprEntry)
assert rep_entry.reprfileloc is not None
assert rep_entry.reprfuncargs is not None
assert rep_entry.reprlocals is not None

a_entry = a_entries[i]
assert isinstance(a_entry, ReprEntry)
assert a_entry.reprfileloc is not None
assert a_entry.reprfuncargs is not None
Expand Down Expand Up @@ -146,9 +145,10 @@ def test_repr_entry_native():

rep_entries = rep.longrepr.reprtraceback.reprentries
a_entries = a.longrepr.reprtraceback.reprentries
for i in range(len(a_entries)):
assert isinstance(rep_entries[i], ReprEntryNative)
assert rep_entries[i].lines == a_entries[i].lines
assert len(rep_entries) == len(a_entries) # python < 3.10 zip(strict=True)
for rep_entry, a_entry in zip(rep_entries, a_entries):
assert isinstance(rep_entry, ReprEntryNative)
assert rep_entry.lines == a_entry.lines

def test_itemreport_outcomes(self, pytester: Pytester) -> None:
# This test came originally from test_remote.py in xdist (ca03269).
Expand Down
6 changes: 2 additions & 4 deletions testing/test_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,8 @@ def pytest_warning_recorded(self, warning_message, when, nodeid, location):
("call warning", "runtest", "test_warning_recorded_hook.py::test_func"),
("teardown warning", "runtest", "test_warning_recorded_hook.py::test_func"),
]
for index in range(len(expected)):
collected_result = collected[index]
expected_result = expected[index]

assert len(collected) == len(expected) # python < 3.10 zip(strict=True)
for collected_result, expected_result in zip(collected, expected):
assert collected_result[0] == expected_result[0], str(collected)
assert collected_result[1] == expected_result[1], str(collected)
assert collected_result[2] == expected_result[2], str(collected)
Expand Down
Loading