missing-maxsplit-arg (PLC0207)
Derived from the Pylint linter.
This rule is unstable and in preview. The --preview
flag is required for use.
What it does
Checks for access to the first or last element of str.split()
or str.rsplit()
without
maxsplit=1
Why is this bad?
Calling str.split()
or str.rsplit()
without passing maxsplit=1
splits on every delimiter in the
string. When accessing only the first or last element of the result, it
would be more efficient to only split once.
Example
Use instead:
To access the last element, use str.rsplit()
instead of str.split()
: