Skip to content

Commit

Permalink
Fix deprecated imports (#635)
Browse files Browse the repository at this point in the history
  • Loading branch information
agners authored Mar 14, 2024
1 parent 72566ce commit 61bf822
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
7 changes: 4 additions & 3 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from __future__ import annotations

import asyncio
from collections.abc import Callable
import logging
from types import TracebackType
from typing import TYPE_CHECKING, Any, Callable, Dict, Final, Optional, cast
from typing import TYPE_CHECKING, Any, Final, Optional, cast
import uuid

from aiohttp import ClientSession
Expand Down Expand Up @@ -62,8 +63,8 @@ def __init__(self, ws_server_url: str, aiohttp_session: ClientSession):
"""Initialize the Client class."""
self.connection = MatterClientConnection(ws_server_url, aiohttp_session)
self.logger = logging.getLogger(__package__)
self._nodes: Dict[int, MatterNode] = {}
self._result_futures: Dict[str, asyncio.Future] = {}
self._nodes: dict[int, MatterNode] = {}
self._result_futures: dict[str, asyncio.Future] = {}
self._subscribers: dict[str, list[Callable[[EventType, Any], None]]] = {}
self._stop_called: bool = False
self._loop: asyncio.AbstractEventLoop | None = None
Expand Down
4 changes: 1 addition & 3 deletions matter_server/common/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

from typing import Type

# mapping from error_code to Exception class
ERROR_MAP: dict[int, type] = {}

Expand Down Expand Up @@ -79,6 +77,6 @@ class InvalidCommand(MatterError):
error_code = 9


def exception_from_error_code(error_code: int) -> Type[MatterError]:
def exception_from_error_code(error_code: int) -> type[MatterError]:
"""Return correct Exception class from error_code."""
return ERROR_MAP.get(error_code, MatterError)
3 changes: 2 additions & 1 deletion matter_server/common/helpers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from __future__ import annotations

from collections.abc import Callable, Coroutine
from dataclasses import MISSING, dataclass
import inspect
from typing import Any, Callable, Coroutine, TypeVar, get_type_hints
from typing import Any, TypeVar, get_type_hints

from matter_server.common.helpers.util import parse_value

Expand Down
3 changes: 2 additions & 1 deletion matter_server/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import Any, Callable
from typing import Any

# Enums and constants

Expand Down
3 changes: 2 additions & 1 deletion matter_server/server/client_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from __future__ import annotations

import asyncio
from collections.abc import Callable
from concurrent import futures
from contextlib import suppress
import logging
from typing import TYPE_CHECKING, Any, Callable, Final
from typing import TYPE_CHECKING, Any, Final

from aiohttp import WSMsgType, web
import async_timeout
Expand Down
3 changes: 2 additions & 1 deletion matter_server/server/device_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

import asyncio
from collections import deque
from collections.abc import Callable, Iterable
from datetime import datetime
from functools import partial
import logging
from pathlib import Path
from random import randint
import time
from typing import TYPE_CHECKING, Any, Callable, Iterable, TypeVar, cast
from typing import TYPE_CHECKING, Any, TypeVar, cast

from chip.ChipDeviceCtrl import DeviceProxyWrapper
from chip.clusters import Attribute, Objects as Clusters
Expand Down
5 changes: 3 additions & 2 deletions matter_server/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from __future__ import annotations

import asyncio
from collections.abc import Callable
from functools import partial
import ipaddress
import logging
import os
from pathlib import Path
import traceback
from typing import TYPE_CHECKING, Any, Callable, Set, cast
from typing import TYPE_CHECKING, Any, cast
import weakref

from aiohttp import web
Expand Down Expand Up @@ -125,7 +126,7 @@ def __init__(
self.vendor_info = VendorInfo(self)
# we dynamically register command handlers
self.command_handlers: dict[str, APICommandHandler] = {}
self._subscribers: Set[EventCallBackType] = set()
self._subscribers: set[EventCallBackType] = set()
self._register_api_commands()

async def start(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions matter_server/server/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import asyncio
import logging
from pathlib import Path
from typing import TYPE_CHECKING, Any, Dict, cast
from typing import TYPE_CHECKING, Any, cast

from ..common.helpers.json import JSON_DECODE_EXCEPTIONS, json_dumps, json_loads

Expand All @@ -22,7 +22,7 @@ class StorageController:
def __init__(self, server: "MatterServer") -> None:
"""Initialize storage controller."""
self.server = server
self._data: Dict[str, Any] = {}
self._data: dict[str, Any] = {}
self._timer_handle: asyncio.TimerHandle | None = None
self._save_lock: asyncio.Lock = asyncio.Lock()

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ ignore = [
"COM812", # Conflict with the Ruff formatter
"ISC001", # Conflict with the Ruff formatter
"TCH003", # TEMPORARY DISABLED
"UP035", # TEMPORARY DISABLED
"TCH002", # TEMPORARY DISABLED
"TID252", # TEMPORARY DISABLED
"N805", # TEMPORARY DISABLED
Expand Down

0 comments on commit 61bf822

Please sign in to comment.