-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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 overload for async singleton call with HassKey #134059
base: dev
Are you sure you want to change the base?
Conversation
Hey there @OttoWinter, @jesserockz, @kbx81, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
|
||
return wrapper | ||
|
||
|
||
async def _test_singleton_typing(hass: HomeAssistant) -> None: |
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 suppose this should go into a test file in tests instead
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 test files aren't type checked. At some point, it might make sense to have a separate test suite for type tests as there are one or two more files these tests but I don't think it's necessary just yet.
One of the other cases:
core/homeassistant/util/hass_dict.pyi
Lines 99 to 104 in 4023409
def _test_hass_dict_typing() -> None: # noqa: PYI048 | |
"""Test HassDict overloads work as intended. | |
This is tested during the mypy run. Do not move it to 'tests'! | |
""" | |
d = HassDict() |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
This PR adds another overload for
singleton
to support decorating async functions withHassKey
asdata_key
. AFAICT this would especially be useful foresphome
(done in this PR) andassist_pipeline
which I'd do in a followup.For type checkers to be able to differentiate the overload definitions, a dummy argument
async_
is added.Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: