django-stubs
django-stubs copied to clipboard
Incomplete type information for `ContextList`
Bug report
The type stub for django.test.ContextList
is incomplete.
What's wrong
https://github.com/typeddjango/django-stubs/blob/master/django-stubs/test/utils.pyi#L44-L46
Is missing __getitem__(str)
and __contains__(str)
. Technically, get(int)
is also missing.
I also think that the type default: Optional[str]
for get
is wrong and should be either Any
or Optional[Any]
.
How is that should be
I suppose a full interface could look something like that: https://mypy-play.net/?mypy=latest&python=3.10&gist=f736dc3a1c40b8ddfa2e15900c0aac53
Although I find it questionable, whether we even want to reveal the full implementation based on list
, or maybe actually just go with something like Mapping[str, Any]
(Actually mapping isn't entirely correct either because it implies Collection[str]
. So more like a custom class that does not inherit list
and has only __getitem__(str)
, __contains__(str)
and keys(str)
.
## System information
- `django-stubs` version: [33d4dc7](https://github.com/typeddjango/django-stubs/commit/33d4dc7dae8fb825d3804887a14d7594dc655abf)
Looks like it has been (mostly) fixed by #1100 . The interface is a bit simpler than my suggestion. Not sure if that has any practical significance though.
Unfortunately I can't fully test with our complex codebase because of another blocker.
[I'll leave the decision to close to the devs.]
I'll close this for now. Feel free to reopen or reply if you're able to test and there are still issues.