-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
UP036 auto-fixer breaks code at runtime after #5766 #6189
Comments
I would like to add another example of the rule breaking code at runtime: from typing import TYPE_CHECKING
if TYPE_CHECKING:
from dependency import MyClass
def my_func():
result: list["MyClass"] = []
return result The quotes around If this should be in a separate issue, please tell me and I will open one |
@clement-escolano -- Hmm, I'm unable to reproduce. This, for example, runs without error for me: from typing import TYPE_CHECKING
if TYPE_CHECKING:
from dependency import MyClass
def my_func():
result: list[MyClass] = []
return result
my_func() Running |
@charliermarsh |
I don't think the dependency has to be installed in order for the above to work, I don't have a dependency called The same is true of the originating comment @mrcljx. This runs fine for me: from typing import Any
import cachetools
class MyClass:
def __init__(self) -> None:
self._cache: cachetools.LRUCache[Any, Any] = cachetools.LRUCache(maxsize=100)
MyClass() |
This is causing some problems, so we'll just revert for now. Closes #6189.
@charliermarsh This indeed seems to have been an IDE bug. Very sorry for bothering you with this report, thanks for Ruff! |
No worries, I went ahead and reverted any way, it seems like it's going to cause some annoyance for folks. |
@mrcljx Which IDE? Did you open an issue there? |
After #5766 the auto-fixer for UP036 has broken some code for us:
The auto-fixer strips the quotes. However this is semantically not valid, as
LRUCache
is notGeneric
at runtime, only for thepyi
files.The text was updated successfully, but these errors were encountered: