Skip to content

Commit

Permalink
Add blog post about core config move (#2433)
Browse files Browse the repository at this point in the history
* Add blog post about core config move

* Update blog/2024-10-31-core-config-moved.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update blog/2024-10-31-core-config-moved.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

* Update 2024-10-31-core-config-moved.md

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Martin Hjelmare <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 317dc4e commit 6295807
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions blog/2024-10-31-core-config-moved.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
author: Erik Montnemery
authorURL: https://github.com/emontnemery
title: "The core config class has been moved"
---

### Summary of changes

The definition of the core config class, an instance of which is available as [`hass.config`](https://developers.home-assistant.io/docs/dev_101_hass/#the-hass-object) has been moved from `homeassistant/core.py` to `homeassistant/core_config.py`. The move was done to make it easier to read and understand the core code. Custom integrations which currently import `Config` from `homeassistant.core` need to be updated to instead import from `homeassistant.core_config`.

:::info
Normally, integrations won't need to use the core `Config` class. But there's been custom integrations that have incorrect type annotations where the `config` object passed to the integration's `async_setup` is specified as a `Config` instance:
```py
from homeassistant.core import Config

async def async_setup(hass: HomeAssistant, config: Config) -> bool:
"""Set up the integration."""
```

A correct type annotation would be like this:
```py
from homeassistant.helpers.typing import ConfigType

async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the integration."""
```
:::


### Backwards compatibility

Until Home Assistant Core 2025.11, it's possible to import from `homeassistant.core`, and doing so will log a warning asking users to open an issue on the custom integration's bug tracker.

0 comments on commit 6295807

Please sign in to comment.