Skip to content

support forward references in argument-position type expressions in stubs #394

@jorenham

Description

@jorenham

The following .pyi snippet is reported as error[unresolved-reference]: Name _WarnLog used when not defined:

_W_co = TypeVar("_W_co", bound=_WarnLog | None, default=_WarnLog | None, covariant=True)
# <snip>

_WarnLog: TypeAlias = list[warnings.WarningMessage]

source:
https://github.com/numpy/numtype/blob/eee4a2cac6ce3401308df497d868a4ba3be975cb/src/numpy-stubs/testing/_private/utils.pyi#L97-L102

Forward references like these should be allowed in .pyi stubs, and there should be no need for a from __future__ import annotations or manual stringification or something

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubsissues with understanding stub (pyi) files

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions