You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can an autofix be created for the preview rule PLW1514 ? Even if it's "unsafe". Updating hundreds of instances manually is quite tedious.
In Python 3.10+ this would autofix to encoding="locale", in Python <=3.9 this would autofix to encoding=locale.getpreferredencoding(False) (see: https://peps.python.org/pep-0597/). Search & replacing those if I want a specific encoding is easier. An option to specify prefered encoding can also be set (which could even be re-used by a new rule that ensures consistent encoding is used with desired value, like "utf-8")
The text was updated successfully, but these errors were encountered:
Avasam
changed the title
PLW1514 autofix
Feature request: PLW1514 autofix
Nov 28, 2023
While I'm working on the general utility mentioned in #8928 (comment), if anyone wants to do the autofix separately in the meantime, feel free to jump in.
## Summary
- Adds `add_argument` similar to existing `remove_argument` utility to
safely add arguments to functions.
- Adds autofix for `PLW1514` as per specs requested in
#8883 as a test
## Test Plan
Checks on existing fixtures as well as additional test and fixture for
Python 3.9 and lower fix
## Issue Link
Closes: #8883
Can an autofix be created for the preview rule
PLW1514
? Even if it's "unsafe". Updating hundreds of instances manually is quite tedious.In Python 3.10+ this would autofix to
encoding="locale"
, in Python <=3.9 this would autofix toencoding=locale.getpreferredencoding(False)
(see: https://peps.python.org/pep-0597/). Search & replacing those if I want a specific encoding is easier. An option to specify prefered encoding can also be set (which could even be re-used by a new rule that ensures consistent encoding is used with desired value, like"utf-8"
)The text was updated successfully, but these errors were encountered: