-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Subclass aiohttp requests to use json helper #90214
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
return json_loads(await self.read()) | ||
|
||
|
||
class HomeAssistantApplication(web.Application): |
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'm not 100% following what is going on here. web.Application
is marked as @final
and the _make_request
function is part of AppRunner
.
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.
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.
It definitely works as-is but I can't explain why .. yet
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.
Oh.
I was looking at aiohttp 4.x which is a major refactor
This is the 3.8.4 code
For 4.x its moved a bit so the below should work for that (maybe still needs some minor tweaks):
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.
After the aiohttp change for the logging no op merges (been through one review pass there already), I'll do another upstream PR to make this a bit easier for when 4.x is released
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.
Doh. My bad for not looking at the right branch.
@@ -240,6 +246,40 @@ def log( | |||
super().log(request, response, time) | |||
|
|||
|
|||
class HomeAssistantRequest(web.Request): |
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 results in a deprecation warning in tests
../../usr/local/lib/python3.10/abc.py:106
/usr/local/lib/python3.10/abc.py:106: DeprecationWarning: Inheritance class HomeAssistantApplication from web.Application is discouraged
inheritance has been deprecated in aiohttp with aio-libs/aiohttp#2692 and will be removed in aiohttp 4.0.0 with aio-libs/aiohttp#3933
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.
See #90214 (comment)
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.
ah sorry, did somehow oversee this comment 🙈
Proposed change
#90194 (comment)
Subclass aiohttp requests to use json helper
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: