-
-
Notifications
You must be signed in to change notification settings - Fork 536
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
Fix ASGI compatibliity on Python 3.12 #911
Conversation
Did this fix the issue for you? Please also add a changelog note and include the |
Yes, this did fix the issue. I added a changelog note, but I'm not sure how to update the tests to get 100% coverage, also should I be adding the |
for more information, see https://pre-commit.ci
For the test coverage issue, have a look at the HTML coverage report in the artifacts section: https://github.com/adamchainz/django-cors-headers/actions/runs/6805112094?pr=911 So basically there is a test missing for the else branch there. |
src/corsheaders/middleware.py
Outdated
result = self.get_response(request) | ||
assert not isinstance(result, HttpResponseBase) | ||
response = await result |
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.
This section did not need changing. The change lead to insufficient test coverage.
It doesn't need changing because when __acall__
is called, we know we're in async mode, and that get_response
will return a coroutine. Mypy just doesn't know that, hence the type-narrowing assert
Alright, I recreated the bug with an example project and have verified this fix works. Thank you both. |
Released in 4.3.1. |
From issue #908, changed middleware.py to reflect the changes made in adamchainz/django-htmx#381 as they had similar issues.