-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Getting unspecified-encoding
with Path().open("w")
#5599
Comments
unspecified-encoding
unspecified-encoding
with Path().open("w")
I believe this is expected behaviour. You're not specifying that the file should be openend in binary mode, so it's openend in text mode making an encoding "required". The issue you're referring to indicated that we did not recognise the binary mode parameter correctly. This has been resolved. |
I do not want to open it in binary mode at all. I want to open it in text mode only, and it is a completely valid python code. It should not raise any warning at all, and IMHO this issue should not be closed. If it is an "expected behaviour", how exactly will you specify the encoding without getting an warning? @DanielNoord @Pierre-Sassoulas (And I know binary mode parameter is solved. Said so myself in the main thread already.) |
@yarnabrina Whether you open in binary or text mode is referred to as the Those docs also refer to as to why we have this check in the first place: default encodings differ per platform and therefore without specifying your encoding your code might fail or run differently on other platforms than the one you're currently working on. Even though it is technically valid. |
I understood from #5017 that it is expected to be solved by version
2.11.1
, but I'm facing same issues even now. I do not get this with binary files ("wb"
) though.Reproducible Example
Code
Folder Structure
❯ tree . └── hello_world.py 0 directories, 1 file
Configuration
None
Invocation Command
(Same happens without
--enable=all
as well)Pylint Output
❯ pylint --enable=all hello_world.py ************* Module hello_world hello_world.py:7:5: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) ------------------------------------------------------------------ Your code has been rated at 7.50/10 (previous run: 7.50/10, +0.00)
Expected Output
None, with perfect score
Setup Information
Pylint Version
OS Version
The text was updated successfully, but these errors were encountered: