-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Use UTF-8 by default for Python files per PEP3120 #21804
Conversation
Hello @jitseniesen! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2024-02-18 20:28:45 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jitseniesen for working on this one! I left a tiny suggestion for you, the rest looks good to me.
Also, please address the problems reported by pep8speaks above. |
1763acf
to
6650e66
Compare
This PR changes how Spyder determines the encoding of files opened in the editor to ensure that we follow PEP3120. For Python files without a declaration of the form "coding=xxx", use UTF-8 as encoding. For other files, we use the chardet library as before. For the purpose of this PR, Python files are those with one of the following extensions: .py, .pyw or .ipy . Also add tests for the new functionality.
This is the extension used by Python type stub files.
6650e66
to
67694ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jitseniesen!
Description of Changes
This PR changes how Spyder determines the encoding of files opened in the editor to ensure that we follow PEP3120.
For Python files without a declaration of the form
coding=xxx
, use UTF-8 as encoding. For other files, we use the chardet library as before.For the purpose of this PR, Python files are those with one of the following extensions:
.py
,.pyw
or.ipy
. This is taken from https://github.com/spyder-ide/spyder/blob/master/spyder/utils/misc.py#L211-L213.Also add tests for the new functionality.
I made this PR as small as possible because we are close to Spyder 6, but the file "encoding.py" can probably be cleaned up a bit. Some code feels like Python 2, with the distinction between text and binary strings. The functions
get_coding()
andread()
have parameters that do not seem to be used.There is related discussion in issue #20510. In particular, this PR fixes the problem noted in #20510 (comment).
Issue(s) Resolved
Fixes #17807
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct:
Jitse Niesen