ruff
ruff copied to clipboard
`PLW1514` does not check for uses of `pathlib.Path.open()` without an explicit encoding argument.
Description
PLW1514 (unspecified-encoding
) does not check for uses of pathlib.Path.open()
without an explicit encoding argument.
But with Pylint, W1514 checks.
I expect Ruff to behave in the same way as Pylint.
sample.py
from pathlib import Path
with open("foo.txt") as f:
f.readline()
with Path("foo.txt").open() as f:
f.readline()
Checks with Ruff
$ ruff --version
ruff 0.4.2
$ ruff check --select PLW1514 --preview --output-format=concise --isolated
sample.py:3:6: PLW1514 `open` in text mode without explicit `encoding` argument
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
Checks with Pylint
$ pylint --version
pylint 3.1.0
astroid 3.1.0
Python 3.12.1 (main, Feb 7 2024, 10:25:21) [GCC 11.4.0]
$ pylint sample.py --enable W1514 --disable C
************* Module sample
sample.py:3:5: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
sample.py:7:5: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
------------------------------------------------------------------
Your code has been rated at 6.00/10 (previous run: 4.00/10, +2.00)