Skip to content

“Cannot resolve forward reference” when using a type variable defined by Python 3.12 type syntax #580

@flying-sheep

Description

@flying-sheep
class Foo[T]:
   def __init__(self, thing: T) -> None: pass

will result in sphinx.errors.SphinxWarning: Cannot resolve forward reference in type annotations of "mylib.Foo": name 'T' is not defined

This should not be the case, as the [T] syntax defines it. See type parameter lists/
PEP 696

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions