diff --git a/homeassistant/components/aprilaire/coordinator.py b/homeassistant/components/aprilaire/coordinator.py index 7a67dee46a8..7674ff070a6 100644 --- a/homeassistant/components/aprilaire/coordinator.py +++ b/homeassistant/components/aprilaire/coordinator.py @@ -4,7 +4,7 @@ from __future__ import annotations from collections.abc import Awaitable, Callable import logging -from typing import Any, Optional +from typing import Any import pyaprilaire.client from pyaprilaire.const import MODELS, Attribute, FunctionalDomain @@ -155,7 +155,7 @@ class AprilaireCoordinator(BaseDataUpdateCoordinatorProtocol): return self.create_device_name(self.data) - def create_device_name(self, data: Optional[dict[str, Any]]) -> str: + def create_device_name(self, data: dict[str, Any] | None) -> str: """Create the name of the thermostat.""" name = data.get(Attribute.NAME) if data else None diff --git a/homeassistant/components/powerwall/__init__.py b/homeassistant/components/powerwall/__init__.py index 5257e5a6299..e9334edb6d5 100644 --- a/homeassistant/components/powerwall/__init__.py +++ b/homeassistant/components/powerwall/__init__.py @@ -5,7 +5,6 @@ from __future__ import annotations from contextlib import AsyncExitStack from datetime import timedelta import logging -from typing import Optional from aiohttp import CookieJar from tesla_powerwall import ( @@ -244,7 +243,7 @@ async def _call_base_info(power_wall: Powerwall, host: str) -> PowerwallBaseInfo ) -async def get_backup_reserve_percentage(power_wall: Powerwall) -> Optional[float]: +async def get_backup_reserve_percentage(power_wall: Powerwall) -> float | None: """Return the backup reserve percentage.""" try: return await power_wall.get_backup_reserve_percentage() diff --git a/pyproject.toml b/pyproject.toml index 49eff55a9dd..8701d67c930 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -760,8 +760,6 @@ ignore = [ "SIM115", # Use context handler for opening files "TRY003", # Avoid specifying long messages outside the exception class "TRY400", # Use `logging.exception` instead of `logging.error` - "UP006", # keep type annotation style as is - "UP007", # keep type annotation style as is # Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923 "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` # Ignored due to incompatible with mypy: https://github.com/python/mypy/issues/15238 diff --git a/tests/components/crownstone/test_config_flow.py b/tests/components/crownstone/test_config_flow.py index d7705e6026b..3525d8c3f53 100644 --- a/tests/components/crownstone/test_config_flow.py +++ b/tests/components/crownstone/test_config_flow.py @@ -3,7 +3,6 @@ from __future__ import annotations from collections.abc import Generator -from typing import Union from unittest.mock import AsyncMock, MagicMock, patch from crownstone_cloud.cloud_models.spheres import Spheres @@ -31,7 +30,7 @@ from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry -MockFixture = Generator[Union[MagicMock, AsyncMock], None, None] +MockFixture = Generator[MagicMock | AsyncMock, None, None] @pytest.fixture(name="crownstone_setup") diff --git a/tests/components/dlna_dms/test_dms_device_source.py b/tests/components/dlna_dms/test_dms_device_source.py index f0eedebb4b3..bb3c9230534 100644 --- a/tests/components/dlna_dms/test_dms_device_source.py +++ b/tests/components/dlna_dms/test_dms_device_source.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Final, Union +from typing import Final from unittest.mock import ANY, Mock, call from async_upnp_client.exceptions import UpnpActionError, UpnpConnectionError, UpnpError @@ -38,7 +38,7 @@ pytestmark = [ ] -BrowseResultList = list[Union[didl_lite.DidlObject, didl_lite.Descriptor]] +BrowseResultList = list[didl_lite.DidlObject | didl_lite.Descriptor] async def async_resolve_media( diff --git a/tests/components/fints/test_client.py b/tests/components/fints/test_client.py index 429d391b07e..398d539d5b9 100644 --- a/tests/components/fints/test_client.py +++ b/tests/components/fints/test_client.py @@ -1,7 +1,5 @@ """Tests for the FinTS client.""" -from typing import Optional - from fints.client import BankIdentifier, FinTSOperations import pytest @@ -51,10 +49,10 @@ BANK_INFORMATION = { ], ) async def test_account_type( - account_number: Optional[str], - iban: Optional[str], + account_number: str | None, + iban: str | None, product_name: str, - account_type: Optional[int], + account_type: int | None, expected_balance_result: bool, expected_holdings_result: bool, ) -> None: diff --git a/tests/components/seventeentrack/conftest.py b/tests/components/seventeentrack/conftest.py index 052d66a4696..2865b3f2599 100644 --- a/tests/components/seventeentrack/conftest.py +++ b/tests/components/seventeentrack/conftest.py @@ -1,7 +1,6 @@ """Configuration for 17Track tests.""" from collections.abc import Generator -from typing import Optional from unittest.mock import AsyncMock, patch from py17track.package import Package @@ -129,7 +128,7 @@ def mock_seventeentrack(): def get_package( tracking_number: str = "456", destination_country: int = 206, - friendly_name: Optional[str] = "friendly name 1", + friendly_name: str | None = "friendly name 1", info_text: str = "info text 1", location: str = "location 1", timestamp: str = "2020-08-10 10:32",