Skip to content

Commit

Permalink
Update some legacy python code to python 3.9 (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 11, 2023
1 parent 712efb9 commit c1a0500
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion aioesphomeapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import asyncio
import logging
from collections.abc import Awaitable, Coroutine
from functools import partial
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Coroutine, Union, cast
from typing import TYPE_CHECKING, Any, Callable, Union, cast

from google.protobuf import message

Expand Down
3 changes: 2 additions & 1 deletion aioesphomeapi/log_runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import logging
from typing import Any, Callable, Coroutine
from collections.abc import Coroutine
from typing import Any, Callable

from zeroconf.asyncio import AsyncZeroconf

Expand Down
5 changes: 3 additions & 2 deletions aioesphomeapi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import enum
import sys
from collections.abc import Iterable
from dataclasses import asdict, dataclass, field, fields
from functools import cache, lru_cache, partial
from typing import TYPE_CHECKING, Any, Callable, Iterable, Optional, TypeVar, cast
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
from uuid import UUID

from .util import fix_float_single_double_conversion
Expand Down Expand Up @@ -768,7 +769,7 @@ class TextInfo(EntityInfo):
min_length: int = 0
max_length: int = 255
pattern: str = ""
mode: Optional[TextMode] = converter_field(
mode: TextMode | None = converter_field(
default=TextMode.TEXT, converter=TextMode.convert
)

Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init tests."""
from __future__ import annotations

import logging

Expand Down
2 changes: 2 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import asyncio
from unittest.mock import AsyncMock, MagicMock, patch

Expand Down
2 changes: 2 additions & 0 deletions tests/test_host_resolver.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import socket
from ipaddress import ip_address
from unittest.mock import AsyncMock, MagicMock, patch
Expand Down
2 changes: 2 additions & 0 deletions tests/test_log_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import asyncio
from unittest.mock import MagicMock, patch

Expand Down
5 changes: 3 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import Optional

import pytest

Expand Down Expand Up @@ -129,7 +130,7 @@ def test_api_int_enum_convert_list(input, output):
@dataclass(frozen=True)
class DummyAPIModel(APIModelBase):
val1: int = 0
val2: Optional[DummyIntEnum] = converter_field(
val2: DummyIntEnum | None = converter_field(
default=DummyIntEnum.DEFAULT, converter=DummyIntEnum.convert
)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_reconnect_logic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import asyncio
import logging
from ipaddress import ip_address
Expand Down

0 comments on commit c1a0500

Please sign in to comment.