Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete type information for ContextList #1055

Closed
tilsche opened this issue Jul 8, 2022 · 2 comments
Closed

Incomplete type information for ContextList #1055

tilsche opened this issue Jul 8, 2022 · 2 comments
Labels
bug Something isn't working stubs Issues in stubs files (.pyi)

Comments

@tilsche
Copy link

tilsche commented Jul 8, 2022

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)
@tilsche tilsche added the bug Something isn't working label Jul 8, 2022
@tilsche
Copy link
Author

tilsche commented Sep 2, 2022

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.]

@intgr intgr added the stubs Issues in stubs files (.pyi) label Nov 8, 2022
@intgr
Copy link
Collaborator

intgr commented Nov 8, 2022

I'll close this for now. Feel free to reopen or reply if you're able to test and there are still issues.

@intgr intgr closed this as completed Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stubs Issues in stubs files (.pyi)
Development

No branches or pull requests

2 participants