Update options flow examples to including typing (#1338)

This commit is contained in:
Allen Porter 2022-05-23 00:12:52 -07:00 committed by GitHub
parent b4884b51f8
commit 04e6cd5406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,10 @@ For an integration to support options it needs to have an `async_get_options_flo
```python
@staticmethod
@callback
def async_get_options_flow(config_entry):
def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> config_entries.OptionsFlow:
"""Create the options flow."""
return OptionsFlowHandler(config_entry)
```
@ -24,11 +27,13 @@ The Flow handler works just like the config flow handler, except that the first
```python
class OptionsFlowHandler(config_entries.OptionsFlow):
def __init__(self, config_entry):
def __init__(self, config_entry: config_entries.ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry
async def async_step_init(self, user_input=None):
async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Manage the options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)