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

Use generic response type for trigger_client_event response parameter and return type. #260

Closed
wants to merge 0 commits into from

Conversation

cjtapper
Copy link
Contributor

Mypy was complaining when I tried to do something like this:

from django.http import HttpResponse
from django_htmx.http import trigger_client_event


response = HttpResponse()
response = trigger_client_event(response, "eventName")

The mypy error:

Incompatible types in assignment (expression has type "HttpResponseBase", variable has type "HttpResponse") [assignment]

Now, I realise that this is partially due to my mypy configuration (and also that I probably didn't really need to assign the return value to that same variable), but this highlights that the return type annotation isn't precise enough. We should expect the return type to be the same subclass of HttpResponseBase as the response argument.

@adamchainz
Copy link
Owner

Thank you, this is better. I added a changelog note and merged in #261.

FYI please don't create PR's from your main branch again, it prevents maintainers from smoothly adding commits to your PR. I tried to do so and this time the change caused GitHub to closed the PR 🤷

@cjtapper
Copy link
Contributor Author

Noted, thanks. Wasn't aware of that!

BTW... There's a typo in my name in the changelog - should be "Tapper", not "Tagger". I opened #262 to fix this (before I saw your response here).

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

Successfully merging this pull request may close these issues.

2 participants