sourcery
sourcery copied to clipboard
Refactor .split("\n") to .splitlines()
Issue description or question
Feature request for refactoring python code to make it more pythonic.
Suggest refactoring .split("\n")
to splitlines()
.
Sourcery Version
v0.11.2
Code editor or IDE name and version
VSCode
OS name and version
Windows
P.S. Sourcery is great!
Hey @alwinw, thank you for this suggestion! I've added it to our pipeline.
The tricky piece here is that this could change functionality since s.split("\n")
and s.splitlines()
behave differently in certain situations (for instance, when s
is an empty string). Could you please share a bit about your use case? Maybe we can determine the right conditions for Sourcery to suggest this change.
Hey @ruancomelli thanks for the speedy response. That's a great point, I didn't realise it behaves differently in some situations.
The primary situation I have in mind is reading a file and converting each line to a string for some subsequent processing.