Skip to content

Warn for incorrect TypeVar usage (with Generics) #16113

@Dreamsorcerer

Description

@Dreamsorcerer

Feature

Sometimes a user less familiar with more advanced typing concepts will use a TypeVar in a way that doesn't add any typing information.

As an example: def foo() -> T:

I think, basically, anytime a TypeVar appears only 1 time in a function (or class) definition, this should be treated as an error.

Pitch

Code like this seems like an obvious sign the user has misunderstood TypeVar, and a warning should probably be emitted. They either want a normal type, or they missed an annotation somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions