Skip to content

Conversation

adamchainz
Copy link
Contributor

I have made things!

Found some view functions in ModelAdmin that take request: Any and decided to expand the search for all such view functions. Then added types to all of them.

Related issues

n/a

@adamchainz adamchainz requested a review from sobolevn October 31, 2022 15:02
Comment on lines 5 to +15
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: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +3 to +6
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: ...
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 16 to 22
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: ...
Copy link
Contributor Author

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

https://github.com/django/django/blob/84206607d6bfd61e7f7a88b51163ffd4153e3b5a/django/views/debug.py#L59-L72

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
Copy link
Contributor Author

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

@adamchainz adamchainz marked this pull request as ready for review October 31, 2022 15:07
Copy link
Member

@sobolevn sobolevn left a 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.

@sobolevn sobolevn merged commit 0381fdb into master Oct 31, 2022
@sobolevn sobolevn deleted the view_types branch October 31, 2022 17:43
@adamchainz
Copy link
Contributor Author

Me neither, I came for the admin, but searched for request: Any and fixed the other places. There are certainly some dark corners inside django.contrib.gis.

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

Successfully merging this pull request may close these issues.

2 participants