-
Notifications
You must be signed in to change notification settings - Fork 2k
UP015 false negatives for many redundant open modes #14235
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
redundant-open-modes (UP015) only recognizes seven redundant modes in Ruff 0.7.3:
ruff/crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs
Lines 112 to 120 in fbf140a
| enum OpenMode { | |
| U, | |
| Ur, | |
| Ub, | |
| RUb, | |
| R, | |
| Rt, | |
| Wt, | |
| } |
However, many other modes are redundant. t and U can always be omitted. r is redundant unless b or + is present. The characters can appear in any order; although the rule handles wt, for example, it misses tw.
More information:
- Python documentation: https://docs.python.org/3.10/library/functions.html#open
- CPython source: https://github.com/python/cpython/blob/v3.10.0/Modules/_io/_iomodule.c#L273
- Full lists of modes: https://github.com/python/typeshed/blob/ea368c72696afba1eb4c12653123edd764c800bf/stdlib/_typeshed/__init__.pyi#L178
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingruleImplementing or modifying a lint ruleImplementing or modifying a lint rule