Skip to content

STYLE: specify encodings when opening files #52963

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

Closed
MarcoGorelli opened this issue Apr 27, 2023 · 8 comments
Closed

STYLE: specify encodings when opening files #52963

MarcoGorelli opened this issue Apr 27, 2023 · 8 comments
Assignees
Labels
Code Style Code style, linting, code_checks good first issue

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Apr 27, 2023

Opening a file without an encoding can cause issues on Windows, there's been some reports from people trying to contribute on Windows running into this

pylint has a check for this, so let's enable it (I've been learning some Rust, so I'll try to get it in to Ruff so it can run in a reasonable amount of time and we can later use that instead - but for now a manual pylint check is fine)

Task here is:

  1. make the following change to .pre-commit-config.yaml
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 43b3699907..34cd91940f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -83,9 +83,6 @@ repos:
     hooks:
     -   id: pylint
         stages: [manual]
--   repo: https://github.com/pycqa/pylint
-    rev: v2.16.2
-    hooks:
     -   id: pylint
         alias: redefined-outer-name
         name: Redefining name from outer scope
@@ -99,6 +96,11 @@ repos:
             |^pandas/conftest\.py  # keep excluded
         args: [--disable=all, --enable=redefined-outer-name]
         stages: [manual]
+    -   id: pylint
+        alias: unspecified-encoding
+        name: Using open without explicitly specifying an encoding
+        args: [--disable=all, --enable=unspecified-encoding]
+        stages: [manual]
 -   repo: https://github.com/PyCQA/isort
     rev: 5.12.0
     hooks:
  1. run pre-commit run unspecified-encoding --hook-stage manual --all-files
  2. fixup all the violations it reports (by using encoding='utf-8'), stage, commit, push, open pull request, celebrate

No need to ask for permission to work on this:

  • just comment take and it will be assigned to you
  • if someone else has commented take a week has passed and they haven't done anything (a common occurrence, unfortunately), then feel free to take over. Please only comment take if you intend to work on this
@MarcoGorelli MarcoGorelli added Code Style Code style, linting, code_checks good first issue labels Apr 27, 2023
@KetuPatel806
Copy link
Contributor

take

@Aniket-Parlikar
Copy link

take

@biscuitdelicious
Copy link

biscuitdelicious commented May 2, 2023

take

any news about the task? @Aniket-Parlikar

@MarcoGorelli
Copy link
Member Author

there's already an open pr...

@MehmetTerc
Copy link

i can take it

@biscuitdelicious
Copy link

i can take it

there is an opened PR already

@tqa236
Copy link
Contributor

tqa236 commented May 19, 2023

@MarcoGorelli I think #52999 (already merged) close this one, right?

@MarcoGorelli
Copy link
Member Author

yup, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants