[Question] rationale for PLW1514 autofix / doc suggesting "locale" instead of "utf-8" ? #11364
Replies: 1 comment
-
The short answer: That being said, I agree that in the documentation, it should steer towards trying to use utf-8 wherever possible. Also after doing this migration in setuptools, I realised that the current suggestion of using |
Beta Was this translation helpful? Give feedback.
-
Although it's been around for a long time, I discovered PLW1514 with the latest ruff release and have been surprised by the fix which made me curious about it.
ruff docs state the following:
And the autofix implemented does the following:
Reading the PEP:
It looks like (from my reading of it):
encoding="locale"
is recommended only when opening text files that have been saved using locale encoding but the overall recommendation (from my understanding) is to useencoding="utf-8"
Finally the example given by ruff differs from the autofix suggested as it gives utf-8 encoding as an example
I understand that
encoding="locale"
is the functional equivalent of not specifying the encoding for now, but from the pep it seems most users would want and potentially should usingutf-8
instead.So I was wondering if there is a specific rationale for steering users towards using "locale" over "utf-8" ?
Thanks! 🙏
@Avasam @qdegraaf @charliermarsh
Beta Was this translation helpful? Give feedback.
All reactions