Skip to content

non-pep695-generic-class (UP046) - false negative on old TypeVar with default argument #20656

@DetachHead

Description

@DetachHead

Summary

from typing import TypeVar, Generic

T = TypeVar("T", default=int)
U = TypeVar("U")


class Foo(Generic[T]): ... # no error
class Bar(Generic[U]): ... # error

https://play.ruff.rs/31611e2c-077c-4291-bdeb-dd663a0f43f7

this behavior is mentioned in the known problems section but i assume this was written before this feature was widely supported by type checkers, and i couldn't find an existing issue for this.

Version

0.13.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    previewRelated to preview mode featuresruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions