Skip to content

Document that stubtest will not flag private names #15414

Open
@rayzchen

Description

@rayzchen

Feature

I would like to have TypeVars in my stubs that do not appear in my source code, but stubtest will flag the typevar as not present at runtime. Therefore, I decided to put them all in if TYPE_CHECKING statements at the beginning of stubs, like:

from typing import TYPE_CHECKING, TypeVar, Generic

if TYPE_CHECKING:
    T = TypeVar("T")

class SomeClass(Generic[T]):
    ...

Pitch

It is not ideal to create a regex for the TypeVar variable names in an allowlist, and it would be much easier to add other type aliases that aren't in the source code but are in stub files.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions