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

Files are being opened without encoding arg #11447

Open
jacobtylerwalls opened this issue Sep 11, 2024 · 1 comment
Open

Files are being opened without encoding arg #11447

jacobtylerwalls opened this issue Sep 11, 2024 · 1 comment

Comments

@jacobtylerwalls
Copy link
Member

jacobtylerwalls commented Sep 11, 2024

Linters like pylint and ruff both discourage opening files without an encoding arg, which can cause problems when files written on one platform are opened on another. Because arches is a general library used cross-platform, this affects us.

One instance that came up was #11337 and was fixed, but there are dozens of other issues you can see if you turn on EncodingWarning (see PEP 597), which you don't need a linter for:

/Users/jwalls/prj/arches/arches/management/commands/load_ontology.py:84: EncodingWarning: 'encoding' argument not specified
  with open(config_file, "r") as f:
/Users/jwalls/prj/arches/tests/base_test.py:129: EncodingWarning: 'encoding' argument not specified

We have a few choices:

  • add utf-8 encoding everywhere
  • or, document that windows users should run python in utf-8 mode
  • or, just want until Python 3.15 when utf-8 mode defaults on, but python has deferred things like this before, so there's no guarantee it will happen on schedule

Suggest adding explict utf-8 encoding and turning on EncodingWarning in CI and elevating it to an error. This will function like a linter without having to decide on adopting a linter like pylint or ruff in general.

(Finally, the django_storages backend allows setting default encoding apparently, but that's only a potential partial fix for that one backend and for files going through the storages interface.)

@chiatt chiatt added this to pipeline Sep 11, 2024
@chiatt
Copy link
Member

chiatt commented Nov 18, 2024

I like the idea of adding explicit encoding with a CI check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants