-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Summary
unspecified-encoding (PLW1514) fails to recognize the encoding parameter of codecs.open when the argument is passed positionally. encoding is at a different position in codecs.open than in open.
$ cat >plw1514.py <<'# EOF'
import codecs
codecs.open("plw1514.py", "r", "utf-8").close()
# EOF
$ python plw1514.py
$ ruff --isolated check plw1514.py --preview --select PLW1514 --unsafe-fixes --fix
Found 1 error (1 fixed, 0 remaining).
$ cat plw1514.py
import codecs
codecs.open("plw1514.py", "r", "utf-8", encoding="utf-8").close()
$ python plw1514.py
Traceback (most recent call last):
File "plw1514.py", line 2, in <module>
codecs.open("plw1514.py", "r", "utf-8", encoding="utf-8").close()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: open() got multiple values for argument 'encoding'Version
ruff 0.11.9 (2370297 2025-05-09)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome