From a194e5ed27729a2691d1c3649999ee021fe340e8 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 31 Mar 2024 15:23:03 +0200 Subject: [PATCH] [pylint 'use-maxsplit-arg'] Do not split more than necessary when using the first element --- pyproject.toml | 1 - src/_pytest/fixtures.py | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e3c64b3e9..c61edeea7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -276,7 +276,6 @@ disable = [ "useless-else-on-loop", "useless-import-alias", "useless-return", - "use-maxsplit-arg", "using-constant-test", "wrong-import-order", ] diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 06da52aed..b7a58081b 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1821,7 +1821,10 @@ def _show_fixtures_per_test(config: Config, session: "Session") -> None: 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) @@ -1903,7 +1906,9 @@ def _showfixtures_main(config: Config, session: "Session") -> None: 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( + tw, doc.split("\n\n", maxsplit=1)[0] if verbose <= 0 else doc + ) else: tw.line(" no docstring available", red=True) tw.line()