Skip to content

Commit c07fca6

Browse files
committed
explicitly pass in the config_entry in azure_devops coordinator init
1 parent 1d243a1 commit c07fca6

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

homeassistant/components/azure_devops/__init__.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
from homeassistant.core import HomeAssistant
1010

1111
from .const import CONF_PAT, CONF_PROJECT
12-
from .coordinator import AzureDevOpsDataUpdateCoordinator
13-
14-
type AzureDevOpsConfigEntry = ConfigEntry[AzureDevOpsDataUpdateCoordinator]
12+
from .coordinator import AzureDevOpsConfigEntry, AzureDevOpsDataUpdateCoordinator
1513

1614
_LOGGER = logging.getLogger(__name__)
1715

@@ -22,11 +20,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AzureDevOpsConfigEntry)
2220
"""Set up Azure DevOps from a config entry."""
2321

2422
# Create the data update coordinator
25-
coordinator = AzureDevOpsDataUpdateCoordinator(
26-
hass,
27-
_LOGGER,
28-
entry=entry,
29-
)
23+
coordinator = AzureDevOpsDataUpdateCoordinator(hass, entry, _LOGGER)
3024

3125
# Store the coordinator in runtime data
3226
entry.runtime_data = coordinator

homeassistant/components/azure_devops/coordinator.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
BUILDS_QUERY: Final = "?queryOrder=queueTimeDescending&maxBuildsPerDefinition=1"
2929
IGNORED_CATEGORIES: Final[list[Category]] = [Category.COMPLETED, Category.REMOVED]
3030

31+
type AzureDevOpsConfigEntry = ConfigEntry[AzureDevOpsDataUpdateCoordinator]
32+
3133

3234
def ado_exception_none_handler(func: Callable) -> Callable:
3335
"""Handle exceptions or None to always return a value or raise."""
@@ -50,28 +52,29 @@ class AzureDevOpsDataUpdateCoordinator(DataUpdateCoordinator[AzureDevOpsData]):
5052
"""Class to manage and fetch Azure DevOps data."""
5153

5254
client: DevOpsClient
55+
config_entry: AzureDevOpsConfigEntry
5356
organization: str
5457
project: Project
5558

5659
def __init__(
5760
self,
5861
hass: HomeAssistant,
62+
config_entry: AzureDevOpsConfigEntry,
5963
logger: logging.Logger,
60-
*,
61-
entry: ConfigEntry,
6264
) -> None:
6365
"""Initialize global Azure DevOps data updater."""
64-
self.title = entry.title
66+
self.title = config_entry.title
6567

6668
super().__init__(
6769
hass=hass,
6870
logger=logger,
71+
config_entry=config_entry,
6972
name=DOMAIN,
7073
update_interval=timedelta(seconds=300),
7174
)
7275

7376
self.client = DevOpsClient(session=async_get_clientsession(hass))
74-
self.organization = entry.data[CONF_ORG]
77+
self.organization = config_entry.data[CONF_ORG]
7578

7679
@ado_exception_none_handler
7780
async def authorize(

homeassistant/components/azure_devops/sensor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
from homeassistant.helpers.typing import StateType
2222
from homeassistant.util import dt as dt_util
2323

24-
from . import AzureDevOpsConfigEntry
25-
from .coordinator import AzureDevOpsDataUpdateCoordinator
24+
from .coordinator import AzureDevOpsConfigEntry, AzureDevOpsDataUpdateCoordinator
2625
from .entity import AzureDevOpsEntity
2726

2827
_LOGGER = logging.getLogger(__name__)

0 commit comments

Comments
 (0)