Skip to content

UP036 auto-fixer breaks code at runtime after #5766 #6189

@mrcljx

Description

@mrcljx

After #5766 the auto-fixer for UP036 has broken some code for us:

from typing import Any

import cachetools

class MyClass:
    def __init__(self) -> None:
        self._cache: "cachetools.LRUCache[Any, Any]" = cachetools.LRUCache(maxsize=100)
ruff --isolated --select UP --fix ruff_up037.py

ruff_up037.py:7:22: UP037 [*] Remove quotes from type annotation

The auto-fixer strips the quotes. However this is semantically not valid, as LRUCache is not Generic at runtime, only for the pyi files.

$ ruff --version
ruff 0.0.280

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions