flake8-simplify
flake8-simplify copied to clipboard
SIM905 false positive
Explanation
SIM905 incorrectly identifies cases where split is used with arguments
Example
This is an example where the mentioned rule(s) would currently be suboptimal:
from pprint import pprint
things = """
some configuration
- a
- b
- more:
- d
- e
""".split("\n")
pprint(things)
SIM905 rule output:
example.py:3:10: SIM905 Use '["some", "configuration", "-", "a", "-", "b", "-", "more:", "-", "d", "-", "e"]' instead of '"
some configuration
- a
- b
- more:
- d
- e
".split()'
This is different from the program output:
$ python example.py
['',
'some configuration',
' - a',
' - b',
' - more:',
' - d',
' - e',
'']
Example with maxsplit
from pprint import pprint
things = """
some configuration
- a
- b
- more:
- d
- e
""".split(sep=None, maxsplit=2)
pprint(things)
SIM905 rule output:
example.py:3:10: SIM905 Use '["some", "configuration", "-", "a", "-", "b", "-", "more:", "-", "d", "-", "e"]' instead of '"
some configuration
- a
- b
- more:
- d
- e
".split()'
This is different from the program output:
$ python example.py
['some', 'configuration', '- a\n - b\n - more:\n - d\n - e\n']