fail typechecking if a parameterized type doesn't declare `__class_getitem__`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
feature
a parameterized (generic) class/type should fail to typecheck if it doesn't have the __class_getitem__ method
pitch
the syntax for parameterized types is SomeClass[int]. however, if SomeClass doesn't define the __class_getitem__ method, this will typecheck but not actually run properly. we ran into this unexpectedly over at typeddjango/django-stubs/issues/507
it would be extremely helpful to at least have a command line option to warn/error on this, just so that nobody runs into it unexpectedly
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the type-checking path for parameterized classes and the existing handling of class_getitem, then inspect nearby tests and command-line option patterns. Done means parameterized types without class_getitem produce the agreed warning or error, with coverage for the behavior and its option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100