Add details about typed ConfigEntry in runtime-data and strict-typing IQS rule (#2479)

This commit is contained in:
epenet 2024-12-10 13:06:12 +01:00 committed by GitHub
parent 295afdefbc
commit fc93ad4978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,7 @@
--- ---
title: "Use ConfigEntry.runtime_data to store runtime data" title: "Use ConfigEntry.runtime_data to store runtime data"
related_rules: related_rules:
- strict-typing
- test-before-setup - test-before-setup
--- ---
import RelatedRules from './_includes/related_rules.jsx' import RelatedRules from './_includes/related_rules.jsx'
@ -35,6 +36,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: MyIntegrationConfigEntry
return True return True
``` ```
:::info
If the integration implements `strict-typing`, the use of a custom typed `MyIntegrationConfigEntry` is required and must be used throughout.
:::
## Additional resources ## Additional resources
More information about configuration entries and their lifecycle can be found in the [config entry documentation](/docs/config_entries_index). More information about configuration entries and their lifecycle can be found in the [config entry documentation](/docs/config_entries_index).
@ -45,4 +50,4 @@ There are no exceptions to this rule.
## Related rules ## Related rules
<RelatedRules relatedRules={frontMatter.related_rules}></RelatedRules> <RelatedRules relatedRules={frontMatter.related_rules}></RelatedRules>

View File

@ -1,6 +1,9 @@
--- ---
title: "Strict typing" title: "Strict typing"
related_rules:
- runtime-data
--- ---
import RelatedRules from './_includes/related_rules.jsx'
## Reasoning ## Reasoning
@ -15,10 +18,18 @@ This file tells mypy that your library is fully typed, after which it can read t
In the Home Assistant codebase, you can add your integration to the [`.strict-typing`](https://github.com/home-assistant/core/blob/dev/.strict-typing) file, which will enable strict type checks for your integration. In the Home Assistant codebase, you can add your integration to the [`.strict-typing`](https://github.com/home-assistant/core/blob/dev/.strict-typing) file, which will enable strict type checks for your integration.
:::warning
If the integration implements `runtime-data`, the use of a custom typed `MyIntegrationConfigEntry` is required and must be used throughout.
:::
## Additional resources ## Additional resources
To read more about the `py.typed` file, see [PEP-561](https://peps.python.org/pep-0561/). To read more about the `py.typed` file, see [PEP-561](https://peps.python.org/pep-0561/).
## Exceptions ## Exceptions
There are no exceptions to this rule. There are no exceptions to this rule.
## Related rules
<RelatedRules relatedRules={frontMatter.related_rules}></RelatedRules>