-
-
Notifications
You must be signed in to change notification settings - Fork 506
Add some types to views #1221
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
Add some types to views #1221
Conversation
def kml( | ||
request: Any, label: Any, model: Any, field_name: Optional[Any] = ..., compress: bool = ..., using: Any = ... | ||
) -> Any: ... | ||
def kmz(request: Any, label: Any, model: Any, field_name: Optional[Any] = ..., using: Any = ...) -> Any: ... | ||
request: HttpRequest, | ||
label: str, | ||
model: str, | ||
field_name: Optional[str] = ..., | ||
compress: bool = ..., | ||
using: str = ..., | ||
) -> HttpResponse: ... | ||
def kmz( | ||
request: HttpRequest, label: str, model: str, field_name: Optional[str] = ..., using: str = ... | ||
) -> HttpResponse: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two views are poorly documented in Django itself: https://docs.djangoproject.com/en/4.1/ref/contrib/gis/sitemaps/
I looked in the source to find types: https://github.com/django/django/blob/2bc47d7fe95ec9fc62bc5c0d2408944e5269d9d0/django/contrib/gis/sitemaps/views.py#L10
And at the related URL patterns, which seem only used in Django’s test suite: https://github.com/django/django/blob/2bc47d7fe95ec9fc62bc5c0d2408944e5269d9d0/tests/gis_tests/geoapp/urls.py#L17-L28
from django.contrib.gis.feeds import Feed | ||
from django.http import HttpRequest, HttpResponse | ||
|
||
def feed(request: HttpRequest, url: str, feed_dict: Optional[Dict[str, Type[Feed]]] = ...) -> HttpResponse: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also poorly documented: https://docs.djangoproject.com/en/4.1/ref/contrib/gis/feeds/
Again poked around to determine types: https://github.com/django/django/blob/84206607d6bfd61e7f7a88b51163ffd4153e3b5a/django/contrib/gis/views.py#L23
def technical_500_response( | ||
request: Any, exc_type: Any, exc_value: Any, tb: Any, status_code: int = ... | ||
request: HttpRequest, | ||
exc_type: Optional[Type[BaseException]], | ||
exc_value: Optional[BaseException], | ||
tb: Optional[TracebackType], | ||
status_code: int = ..., | ||
) -> HttpResponse: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The args are all passed on to ExceptionReporter
which we have types for below
def get_model_perms(self, request: HttpRequest) -> Dict[str, bool]: ... | ||
def get_form( | ||
self, request: Any, obj: Optional[_ModelT] = ..., change: bool = ..., **kwargs: Any | ||
self, request: HttpRequest, obj: Optional[_ModelT] = ..., change: bool = ..., **kwargs: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all the Django admin changes I read the source, request
seems consistently used for HttpRequest
throughout, as you'd hope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never used this part of Django! Thank you.
Me neither, I came for the admin, but searched for |
I have made things!
Found some view functions in
ModelAdmin
that takerequest: Any
and decided to expand the search for all such view functions. Then added types to all of them.Related issues
n/a