-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
PYI034 false positive if Self is a quoted annotation #12928
Comments
Please feel free! We have logic elsewhere for handling quoted annotations, so I'd definitely go and check how other rules do this kind of thing first |
I think this might be more of a fundamental issue. If I extend the example: import typing as t
if t.TYPE_CHECKING:
from typing import Any
from typing_extensions import Self
class Foo:
def __init__(self, x: int) -> None:
self.x = x
def __iadd__(self, other: "Self") -> "Self":
self.x += other.x
return self
def __eq__(self, value: "Any") -> bool:
return True PYI031 should pick up the I've been combing through the code on how to resolve it but I'm struggling. Any suggestions? |
Hmm, yeah, this was a bit more complicated than I realised. Unfortunately in order to figure out how to fix it, I've basically had to go ahead and implement the fix locally, so I might just go ahead and file a PR myself if that's okay :/ Sorry -- I thought this was a good contributor issue but I think I was mistaken. |
I've filed #12951 |
Thanks @AlexWaygood! No worries about taking over, I'm certain I would have never come up with that fix. |
List of keywords searched:
Code example:
Command:
ruff check file.py --isolated --select=PYI034
Ruff Version: 0.5.7
I'd be happy to try and fix this as I have some Rust experience. Please let me know if I can be of help.
The text was updated successfully, but these errors were encountered: