Skip to content
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

[Core] Explicit encoding for opening files and update pylint #3153

Merged
merged 5 commits into from
Feb 14, 2024

Conversation

Michaelvll
Copy link
Collaborator

Fixes #3152

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Michaelvll! Looks like we need to be careful about all open() calls.

As an alternative, can we somehow globally set to use utf-8 for all calls? That reduces chances of bugs if a developer forgets to add encoding='utf-8'.

Looks like the UTF-8 mode aims to do so, and can be forced by setting PYTHONUTF8=1 environment variable. Any way we can use this?

@Michaelvll
Copy link
Collaborator Author

Thanks @Michaelvll! Looks like we need to be careful about all open() calls.

As an alternative, can we somehow globally set to use utf-8 for all calls? That reduces chances of bugs if a developer forgets to add encoding='utf-8'.

Looks like the UTF-8 mode aims to do so, and can be forced by setting PYTHONUTF8=1 environment variable. Any way we can use this?

Thanks for pointing that out @romilbhardwaj! It seems that explicitly specifying the encoding for every open is a recommended practice according to the PEP standard: https://peps.python.org/pep-0597/ and also a warning in pylint: https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/unspecified-encoding.html

It might be a good chance for us to add the encoding everywhere in our code and updating our pylint version. Wdyt?

@Michaelvll Michaelvll changed the title [Core] Explicit encoding for opening files [Core] Explicit encoding for opening files and update pylint Feb 13, 2024
Copy link
Collaborator

@romilbhardwaj romilbhardwaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Michaelvll! Adding to pylint check is a good idea. LGTM.

.pylintrc Show resolved Hide resolved
@Michaelvll Michaelvll merged commit 5cc68d2 into master Feb 14, 2024
19 checks passed
@Michaelvll Michaelvll deleted the fix-log-encoding branch February 14, 2024 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core] Logging raises encoding error
2 participants