Skip to content
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

Feature Request: Exclude lines from conversion with a comment #809

Closed
BranislavBajuzik opened this issue Mar 23, 2023 · 1 comment
Closed

Comments

@BranislavBajuzik
Copy link

BranislavBajuzik commented Mar 23, 2023

A continuation of a closed and locked issue, #574

I do understand that pyupgrade is an opinionated tool. It is, however, not a perfect one. There are cases where the fix introduces a bug.

My options then are:

  1. Not use the tool at all, even tho 99.9% of the time it works perfectly
  2. If I'm lucky, and there is a flag to disable a fix, I can then disable it across the whole project (--keep-mock, --keep-runtime-typing, and --keep-percent-format)
    • This is curious, because configuration is allowed despite the opinionated nature
  3. I can blacklist the problematic file

I would love a 4th option that allows me to disable a single line.

In my case, I have a dataclass that uses slots=True. There is a problem with super in there, as described in this SO answer so I need to explicitly call super(MyClass, self) and it works.

The problem is that pyupgrade then comes along and removes it, assuming that it is always safe to do so (this assumption is wrong, as this is Python, where things can change during runtime, not C)
All of the widely used tools, even opinionated black allow for exceptions for this reason. A simple # nopyupgrade and possibly # pyupgrade: off+# pyupgrade: on would fix this.

Thank you

@asottile
Copy link
Owner

no means no

Repository owner locked as spam and limited conversation to collaborators Mar 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants