Visitar URL original
Use `TypeForm` in __class_getitem__ for generics? · Issue #15770 · python/typeshed · GitHub
Skip to content

Use TypeForm in __class_getitem__ for generics? #15770

Description

@Andrew5057

Now that TypeForm is in 3.15+ and typing_extensions, would it be reasonable to start using it in the __class_getitem__ stubs for generic classes? That way, we could reject constructs like list[3] without triggering false positives on things that are valid type expressions but not types.

Activity

  1. JelleZijlstra commented on May 11, 2026

    @JelleZijlstra
    Member

    Worth trying, I think.

    Type checkers might not fully support TypeForm yet, but if they don't the type should generally degrade to Any, which is no worse than the current situation.

  2. Andrew5057 commented on May 12, 2026

    @Andrew5057
    ContributorAuthor

    mypy is actually throwing errors without --enable-incomplete-feature=TypeForm, so seems like we should hold off for a bit. I might make a draft PR though.

  3. jonathandung commented on Jul 16, 2026

    @jonathandung
    Contributor

    Maybe provisionally add that in the command in the run_mypy_as_subprocess() body here.

    Not sure if that still applies since typeshed now runs tests on more type checkers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions