From 3e8d6bb01eadde0d6d780caf80bc52f84e074f6b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 18 Sep 2023 14:05:39 +0200 Subject: [PATCH] Removed `typing-extensions` dependency. The package isn't present on older versions of Debian. --- platypush/backend/http/app/streaming/_base.py | 3 --- platypush/backend/http/app/streaming/plugins/camera.py | 3 --- platypush/backend/http/app/streaming/plugins/sound.py | 3 --- platypush/backend/http/app/ws/_base.py | 6 ------ platypush/backend/http/app/ws/events.py | 6 ------ platypush/backend/http/app/ws/requests.py | 2 -- platypush/commands/_commands/_app_ctrl.py | 4 ---- platypush/commands/_stream.py | 3 --- platypush/entities/bluetooth/_device.py | 2 -- platypush/entities/bluetooth/_service.py | 3 --- platypush/entities/managers/switches.py | 2 -- platypush/install/requirements/alpine.txt | 1 - platypush/install/requirements/debian.txt | 1 - platypush/message/event/assistant/__init__.py | 2 -- platypush/platydock/__init__.py | 6 ------ platypush/platyvenv/__init__.py | 4 ---- platypush/plugins/__init__.py | 3 --- platypush/plugins/arduino/__init__.py | 2 -- platypush/plugins/bluetooth/_ble/_cache.py | 7 ------- platypush/plugins/bluetooth/_ble/_manager.py | 8 -------- platypush/plugins/bluetooth/_ble/_plugins/switchbot.py | 4 ---- platypush/plugins/bluetooth/_cache.py | 8 -------- platypush/plugins/bluetooth/_legacy/_manager/_base.py | 9 --------- platypush/plugins/bluetooth/_plugin.py | 7 ------- platypush/plugins/inspect/_parsers/_backend.py | 2 -- platypush/plugins/inspect/_parsers/_event.py | 2 -- platypush/plugins/inspect/_parsers/_method.py | 2 -- platypush/plugins/inspect/_parsers/_plugin.py | 2 -- platypush/plugins/inspect/_parsers/_response.py | 2 -- platypush/plugins/inspect/_parsers/_schema.py | 2 -- platypush/plugins/linode/__init__.py | 9 --------- platypush/plugins/mqtt/__init__.py | 3 --- platypush/plugins/sensor/__init__.py | 4 ---- platypush/plugins/sensor/bme280/__init__.py | 3 --- platypush/plugins/sensor/dht/__init__.py | 5 +---- platypush/plugins/sensor/distance/vl53l1x/__init__.py | 3 --- platypush/plugins/sensor/envirophat/__init__.py | 3 --- platypush/plugins/sensor/hcsr04/__init__.py | 4 ---- platypush/plugins/sensor/lis3dh/__init__.py | 3 --- platypush/plugins/sensor/ltr559/__init__.py | 4 ---- platypush/plugins/sensor/mcp3008/__init__.py | 3 --- platypush/plugins/sensor/pmw3901/__init__.py | 3 --- platypush/plugins/serial/__init__.py | 5 ----- platypush/plugins/sound/__init__.py | 2 -- platypush/plugins/sound/_converters/_from_raw.py | 3 --- platypush/plugins/sound/_converters/_to_raw.py | 4 ---- platypush/plugins/sound/_streams/_base.py | 2 -- platypush/plugins/sound/_streams/_player/_base.py | 10 ---------- platypush/plugins/sound/_streams/_player/_resource.py | 5 ----- .../plugins/sound/_streams/_player/_synth/_mix.py | 2 -- .../plugins/sound/_streams/_player/_synth/_player.py | 6 ------ .../plugins/sound/_streams/_player/_synth/_sound.py | 2 -- platypush/plugins/sound/_streams/_recorder.py | 10 ---------- platypush/plugins/system/__init__.py | 4 ---- platypush/plugins/variable/__init__.py | 3 --- platypush/plugins/xmpp/__init__.py | 4 ---- platypush/plugins/xmpp/_handlers/_registry.py | 2 -- platypush/plugins/xmpp/_handlers/_room.py | 2 -- platypush/plugins/xmpp/_handlers/_roster.py | 3 +-- platypush/plugins/xmpp/_mixins/_event_state.py | 2 -- platypush/plugins/zigbee/mqtt/__init__.py | 4 ---- platypush/plugins/zwave/mqtt/__init__.py | 4 ---- platypush/process/__init__.py | 2 -- platypush/runner/_app.py | 3 --- platypush/utils/manifest.py | 3 --- 65 files changed, 2 insertions(+), 243 deletions(-) diff --git a/platypush/backend/http/app/streaming/_base.py b/platypush/backend/http/app/streaming/_base.py index 0e698617c..d5646751f 100644 --- a/platypush/backend/http/app/streaming/_base.py +++ b/platypush/backend/http/app/streaming/_base.py @@ -3,7 +3,6 @@ from http.client import responses import json from logging import getLogger from typing import Optional -from typing_extensions import override from tornado.web import RequestHandler, stream_request_body @@ -22,7 +21,6 @@ class StreamingRoute(RequestHandler, PubSubMixin, ABC): super().__init__(*args, **kwargs) self.logger = getLogger(__name__) - @override def prepare(self): """ Request preparation logic. It performs user authentication if @@ -38,7 +36,6 @@ class StreamingRoute(RequestHandler, PubSubMixin, ABC): 'Client %s connected to %s', self.request.remote_ip, self.request.path ) - @override def write_error(self, status_code: int, error: Optional[str] = None, **_): """ Make sure that errors are always returned in JSON format. diff --git a/platypush/backend/http/app/streaming/plugins/camera.py b/platypush/backend/http/app/streaming/plugins/camera.py index cde01592e..a998e0dbb 100644 --- a/platypush/backend/http/app/streaming/plugins/camera.py +++ b/platypush/backend/http/app/streaming/plugins/camera.py @@ -1,7 +1,6 @@ from enum import Enum import json from typing import Optional -from typing_extensions import override from tornado.web import stream_request_body from platypush.context import get_plugin @@ -37,7 +36,6 @@ class CameraRoute(StreamingRoute): self._request_type = RequestType.UNKNOWN self._extension: str = '' - @override @classmethod def path(cls) -> str: return r"/camera/([a-zA-Z0-9_./]+)/([a-zA-Z0-9_]+)\.?([a-zA-Z0-9_]+)?" @@ -95,7 +93,6 @@ class CameraRoute(StreamingRoute): return kwargs - @override @classmethod def _get_redis_queue(cls, camera: CameraPlugin, *_, **__) -> str: plugin_name = get_plugin_name_by_class(camera.__class__) diff --git a/platypush/backend/http/app/streaming/plugins/sound.py b/platypush/backend/http/app/streaming/plugins/sound.py index fb7a3e8cd..4101da841 100644 --- a/platypush/backend/http/app/streaming/plugins/sound.py +++ b/platypush/backend/http/app/streaming/plugins/sound.py @@ -1,7 +1,6 @@ from contextlib import contextmanager import json from typing import Generator, Optional -from typing_extensions import override from tornado.web import stream_request_body @@ -24,7 +23,6 @@ class SoundRoute(StreamingRoute): self._audio_headers_written: bool = False """Send the audio file headers before we send the first audio frame.""" - @override @classmethod def path(cls) -> str: return r"/sound/stream\.?([a-zA-Z0-9_]+)?" @@ -44,7 +42,6 @@ class SoundRoute(StreamingRoute): yield send_request('sound.stop_recording') - @override @classmethod def _get_redis_queue(cls, *_, device: Optional[str] = None, **__) -> str: return '/'.join([cls._redis_queue_prefix, *([device] if device else [])]) diff --git a/platypush/backend/http/app/ws/_base.py b/platypush/backend/http/app/ws/_base.py index 40274b717..3f2ba3d08 100644 --- a/platypush/backend/http/app/ws/_base.py +++ b/platypush/backend/http/app/ws/_base.py @@ -1,7 +1,6 @@ from abc import ABC, abstractmethod from logging import getLogger from threading import Thread -from typing_extensions import override from tornado.ioloop import IOLoop from tornado.websocket import WebSocketHandler @@ -24,7 +23,6 @@ class WSRoute(WebSocketHandler, Thread, PubSubMixin, ABC): Thread.__init__(self) self._io_loop = IOLoop.current() - @override def open(self, *_, **__): auth_status = get_auth_status(self.request) if auth_status != AuthStatus.OK: @@ -37,11 +35,9 @@ class WSRoute(WebSocketHandler, Thread, PubSubMixin, ABC): self.name = f'ws:{self.app_name()}@{self.request.remote_ip}' self.start() - @override def data_received(self, *_, **__): pass - @override def on_message(self, message): return message @@ -63,12 +59,10 @@ class WSRoute(WebSocketHandler, Thread, PubSubMixin, ABC): self.write_message, self._serialize(msg) ) - @override def run(self) -> None: super().run() self.subscribe(*self._subscriptions) - @override def on_close(self): super().on_close() for channel in self._subscriptions.copy(): diff --git a/platypush/backend/http/app/ws/events.py b/platypush/backend/http/app/ws/events.py index 53751ebbc..2bc830a59 100644 --- a/platypush/backend/http/app/ws/events.py +++ b/platypush/backend/http/app/ws/events.py @@ -1,5 +1,3 @@ -from typing_extensions import override - from platypush.backend.http.app.mixins import MessageType from platypush.message.event import Event @@ -16,7 +14,6 @@ class WSEventProxy(WSRoute): super().__init__(*args, subscriptions=[self.events_channel], **kwargs) @classmethod - @override def app_name(cls) -> str: return 'events' @@ -25,12 +22,10 @@ class WSEventProxy(WSRoute): def events_channel(cls) -> str: return cls.get_channel('events') - @override @classmethod def publish(cls, data: MessageType, *_) -> None: super().publish(data, cls.events_channel) - @override def on_message(self, message): try: event = Event.build(message) @@ -42,7 +37,6 @@ class WSEventProxy(WSRoute): send_message(event, wait_for_response=False) - @override def run(self) -> None: for msg in self.listen(): try: diff --git a/platypush/backend/http/app/ws/requests.py b/platypush/backend/http/app/ws/requests.py index 6fec50f76..f8ac6e241 100644 --- a/platypush/backend/http/app/ws/requests.py +++ b/platypush/backend/http/app/ws/requests.py @@ -1,6 +1,5 @@ from threading import Thread, current_thread from typing import Set -from typing_extensions import override from platypush.backend.http.app.utils import send_message from platypush.message.request import Request @@ -21,7 +20,6 @@ class WSRequestsProxy(WSRoute): self._requests: Set[Thread] = set() @classmethod - @override def app_name(cls) -> str: return 'requests' diff --git a/platypush/commands/_commands/_app_ctrl.py b/platypush/commands/_commands/_app_ctrl.py index 780d8b15c..f47d8b17e 100644 --- a/platypush/commands/_commands/_app_ctrl.py +++ b/platypush/commands/_commands/_app_ctrl.py @@ -1,5 +1,3 @@ -from typing_extensions import override - from platypush.commands import Command @@ -8,7 +6,6 @@ class StopCommand(Command): Stop the application. """ - @override def __call__(self, app, *_, **__): self.logger.info('Received StopApplication command.') app.stop() @@ -19,7 +16,6 @@ class RestartCommand(Command): Restart the application. """ - @override def __call__(self, app, *_, **__): self.logger.info('Received RestartApplication command.') app.restart() diff --git a/platypush/commands/_stream.py b/platypush/commands/_stream.py index 99d12b4c9..3e480c11c 100644 --- a/platypush/commands/_stream.py +++ b/platypush/commands/_stream.py @@ -4,7 +4,6 @@ from queue import Empty import socket import tempfile from typing import Optional -from typing_extensions import override from platypush.process import ControllableProcess @@ -54,7 +53,6 @@ class CommandStream(ControllableProcess): self._cmd_queue.close() self._cmd_queue = Queue() - @override def close(self) -> None: self.reset() return super().close() @@ -134,7 +132,6 @@ class CommandStream(ControllableProcess): except OSError: pass - @override def main(self): while self._sock and not self.should_stop: sock = self._sock diff --git a/platypush/entities/bluetooth/_device.py b/platypush/entities/bluetooth/_device.py index 25694489e..a2e9d8a85 100644 --- a/platypush/entities/bluetooth/_device.py +++ b/platypush/entities/bluetooth/_device.py @@ -1,5 +1,4 @@ from typing import Iterable, List -from typing_extensions import override from sqlalchemy import ( Boolean, @@ -156,7 +155,6 @@ if 'bluetooth_device' not in Base.metadata: and child.service_class != ServiceClass.UNKNOWN } - @override def to_dict(self): """ Overwrites ``to_dict`` to transform private column names into their diff --git a/platypush/entities/bluetooth/_service.py b/platypush/entities/bluetooth/_service.py index 65a9b43db..5b2bf1eb2 100644 --- a/platypush/entities/bluetooth/_service.py +++ b/platypush/entities/bluetooth/_service.py @@ -1,7 +1,5 @@ from uuid import UUID -from typing_extensions import override - from sqlalchemy import ( Boolean, Column, @@ -128,7 +126,6 @@ if 'bluetooth_service' not in Base.metadata: except (TypeError, ValueError): return ServiceClass.UNKNOWN - @override def to_dict(self) -> dict: return { **{k.lstrip('_'): v for k, v in super().to_dict().items()}, diff --git a/platypush/entities/managers/switches.py b/platypush/entities/managers/switches.py index 5fa54a4d2..d6b6f4f69 100644 --- a/platypush/entities/managers/switches.py +++ b/platypush/entities/managers/switches.py @@ -1,6 +1,5 @@ from abc import ABC, abstractmethod from typing import Any -from typing_extensions import override from . import EntityManager @@ -42,7 +41,6 @@ class SwitchEntityManager(WriteableEntityManager, ABC): """Toggle the state of a device (on->off or off->on)""" raise NotImplementedError() - @override def set(self, entity: str, value: Any, **kwargs): method = self.on if value else self.off return method(entity, **kwargs) diff --git a/platypush/install/requirements/alpine.txt b/platypush/install/requirements/alpine.txt index e9f2b4773..06c917aa0 100644 --- a/platypush/install/requirements/alpine.txt +++ b/platypush/install/requirements/alpine.txt @@ -15,7 +15,6 @@ py3-requests py3-rsa py3-sqlalchemy py3-tornado -py3-typing-extensions py3-tz py3-websocket-client py3-websockets diff --git a/platypush/install/requirements/debian.txt b/platypush/install/requirements/debian.txt index d7fdd1aa7..4d43ac766 100644 --- a/platypush/install/requirements/debian.txt +++ b/platypush/install/requirements/debian.txt @@ -16,7 +16,6 @@ python3-requests python3-rsa python3-sqlalchemy python3-tornado -python3-typing-extensions python3-typing-inspect python3-tz python3-websocket diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index 1ca2049e6..01a21eb56 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -1,7 +1,6 @@ import logging import re import sys -from typing_extensions import override from platypush.context import get_backend, get_plugin from platypush.message.event import Event @@ -104,7 +103,6 @@ class SpeechRecognizedEvent(AssistantEvent): return result - @override def _matches_argument(self, argname, condition_value, event_args, result): """ Overrides the default `_matches_argument` method to allow partial diff --git a/platypush/platydock/__init__.py b/platypush/platydock/__init__.py index 7ad3eb74c..ed97dbffb 100755 --- a/platypush/platydock/__init__.py +++ b/platypush/platydock/__init__.py @@ -14,7 +14,6 @@ import subprocess import sys import textwrap from typing import IO, Generator, Iterable -from typing_extensions import override from platypush.builder import BaseBuilder from platypush.config import Config @@ -73,12 +72,10 @@ class DockerBuilder(BaseBuilder): self.tag = tag self.print_only = print_only # TODO - @override @classmethod def get_name(cls): return "platydock" - @override @classmethod def get_description(cls): return "Build a Platypush Docker image from a configuration file." @@ -133,7 +130,6 @@ class DockerBuilder(BaseBuilder): yield line.rstrip() @property - @override def deps(self) -> Dependencies: return Dependencies.from_config( self.cfgfile, @@ -187,7 +183,6 @@ class DockerBuilder(BaseBuilder): return parser - @override def build(self): """ Build a Dockerfile based on a configuration file. @@ -292,7 +287,6 @@ class DockerBuilder(BaseBuilder): ) @classmethod - @override def _get_arg_parser(cls) -> argparse.ArgumentParser: parser = super()._get_arg_parser() diff --git a/platypush/platyvenv/__init__.py b/platypush/platyvenv/__init__.py index 0564b719f..3e1aa83f4 100755 --- a/platypush/platyvenv/__init__.py +++ b/platypush/platyvenv/__init__.py @@ -15,8 +15,6 @@ import textwrap from typing import Generator, Sequence import venv -from typing_extensions import override - from platypush.builder import BaseBuilder from platypush.config import Config from platypush.utils.manifest import ( @@ -36,12 +34,10 @@ class VenvBuilder(BaseBuilder): kwargs['install_context'] = InstallContext.DOCKER super().__init__(*args, **kwargs) - @override @classmethod def get_name(cls): return "platyvenv" - @override @classmethod def get_description(cls): return "Build a Platypush virtual environment from a configuration file." diff --git a/platypush/plugins/__init__.py b/platypush/plugins/__init__.py index b53308653..3615f921b 100644 --- a/platypush/plugins/__init__.py +++ b/platypush/plugins/__init__.py @@ -6,7 +6,6 @@ import warnings from abc import ABC, abstractmethod from functools import wraps from typing import Any, Callable, Optional -from typing_extensions import override from platypush.bus import Bus from platypush.common import ExtensionWithManifest @@ -279,7 +278,6 @@ class AsyncRunnablePlugin(RunnablePlugin, ABC): self._task.cancel() - @override def main(self): if self.should_stop(): self.logger.info('The plugin is already scheduled to stop') @@ -296,7 +294,6 @@ class AsyncRunnablePlugin(RunnablePlugin, ABC): else: self.wait_stop() - @override def stop(self): if self._loop and self._loop.is_running(): self._loop.call_soon_threadsafe(self._loop.stop) diff --git a/platypush/plugins/arduino/__init__.py b/platypush/plugins/arduino/__init__.py index 40fb2b172..06b00543b 100644 --- a/platypush/plugins/arduino/__init__.py +++ b/platypush/plugins/arduino/__init__.py @@ -2,7 +2,6 @@ import enum import time from typing import List, Optional, Dict, Union, Callable, Tuple, Type -from typing_extensions import override from pyfirmata2 import ( Arduino, @@ -485,7 +484,6 @@ class ArduinoPlugin(SensorPlugin): return ret - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: # type: ignore dev_id = 'arduino' dev_name = 'Arduino' diff --git a/platypush/plugins/bluetooth/_ble/_cache.py b/platypush/plugins/bluetooth/_ble/_cache.py index c875cd8f9..5e4f49ae2 100644 --- a/platypush/plugins/bluetooth/_ble/_cache.py +++ b/platypush/plugins/bluetooth/_ble/_cache.py @@ -1,5 +1,4 @@ from typing import Dict, Iterable, Optional, Tuple -from typing_extensions import override from bleak.backends.device import BLEDevice @@ -15,27 +14,21 @@ class DeviceCache(BaseCache): _by_name: Dict[str, BLEDevice] @property - @override def _address_field(self) -> str: return 'address' @property - @override def _name_field(self) -> str: return 'name' - @override def get(self, device: str) -> Optional[BLEDevice]: return super().get(device) - @override def add(self, device: BLEDevice) -> BLEDevice: return super().add(device) - @override def values(self) -> Iterable[BLEDevice]: return super().values() - @override def items(self) -> Iterable[Tuple[str, BLEDevice]]: return super().items() diff --git a/platypush/plugins/bluetooth/_ble/_manager.py b/platypush/plugins/bluetooth/_ble/_manager.py index a2db3d47c..3dc5ecb7f 100644 --- a/platypush/plugins/bluetooth/_ble/_manager.py +++ b/platypush/plugins/bluetooth/_ble/_manager.py @@ -14,7 +14,6 @@ from typing import ( from bleak import BleakClient, BleakScanner from bleak.backends.device import BLEDevice from bleak.exc import BleakError -from typing_extensions import override from platypush.context import get_or_create_event_loop from platypush.entities.bluetooth import BluetoothDevice @@ -256,7 +255,6 @@ class BLEManager(BaseBluetoothManager): entity.connected = False self.notify(BluetoothDeviceDisconnectedEvent, entity) - @override def connect( self, device: str, @@ -299,7 +297,6 @@ class BLEManager(BaseBluetoothManager): success = connected_event.wait(timeout=timeout) assert success, f'Connection to {device} timed out' - @override def disconnect(self, device: str, *_, **__): # Get the device loop = get_or_create_event_loop() @@ -323,7 +320,6 @@ class BLEManager(BaseBluetoothManager): connection.thread and connection.thread.is_alive() ), f'Disconnection from {device} timed out' - @override def scan( self, duration: Optional[float] = None, @@ -340,7 +336,6 @@ class BLEManager(BaseBluetoothManager): loop = get_or_create_event_loop() return loop.run_until_complete(self._scan(duration, service_uuids)) - @override def read( self, device: str, @@ -360,7 +355,6 @@ class BLEManager(BaseBluetoothManager): self._read(device, service_uuid, interface, connect_timeout) ) - @override def write( self, device: str, @@ -401,7 +395,6 @@ class BLEManager(BaseBluetoothManager): device_addresses = new_device_addresses - @override def run(self): super().run() @@ -420,7 +413,6 @@ class BLEManager(BaseBluetoothManager): except Exception: pass - @override def stop(self): """ Upon stop request, it stops any pending scans and closes all active diff --git a/platypush/plugins/bluetooth/_ble/_plugins/switchbot.py b/platypush/plugins/bluetooth/_ble/_plugins/switchbot.py index 84741468a..442f22bfb 100644 --- a/platypush/plugins/bluetooth/_ble/_plugins/switchbot.py +++ b/platypush/plugins/bluetooth/_ble/_plugins/switchbot.py @@ -2,8 +2,6 @@ from enum import Enum from typing import Iterable from uuid import UUID -from typing_extensions import override - from platypush.entities import Entity from platypush.entities.bluetooth import BluetoothDevice from platypush.entities.switches import EnumSwitch @@ -45,13 +43,11 @@ class SwitchbotPlugin(BaseBluetoothPlugin): Implements support for Switchbot devices. """ - @override def supports_device(self, device: BluetoothDevice) -> bool: return any( srv.service_class == ServiceClass.SWITCHBOT for srv in device.services ) - @override def _extract_entities(self, device: BluetoothDevice) -> Iterable[Entity]: return [ EnumSwitch( diff --git a/platypush/plugins/bluetooth/_cache.py b/platypush/plugins/bluetooth/_cache.py index 02c75903a..9649ac3c2 100644 --- a/platypush/plugins/bluetooth/_cache.py +++ b/platypush/plugins/bluetooth/_cache.py @@ -2,7 +2,6 @@ from abc import ABC, abstractmethod from collections import defaultdict from threading import RLock from typing import Any, Dict, Iterable, Optional, Tuple, Union -from typing_extensions import override from platypush.entities.bluetooth import BluetoothDevice @@ -95,21 +94,17 @@ class EntityCache(BaseCache): _by_name: Dict[str, BluetoothDevice] @property - @override def _address_field(self) -> str: return 'address' @property - @override def _name_field(self) -> str: return 'name' - @override def get(self, device: Union[str, BluetoothDevice]) -> Optional[BluetoothDevice]: dev_filter = device.address if isinstance(device, BluetoothDevice) else device return super().get(dev_filter) - @override def add(self, device: BluetoothDevice) -> BluetoothDevice: with self._insert_locks[device.address]: existing_device = self.get(device) @@ -120,15 +115,12 @@ class EntityCache(BaseCache): return super().add(device) - @override def values(self) -> Iterable[BluetoothDevice]: return super().values() - @override def items(self) -> Iterable[Tuple[str, BluetoothDevice]]: return super().items() - @override def __contains__(self, device: Union[str, BluetoothDevice]) -> bool: """ Override the default ``__contains__`` to support lookup by partial diff --git a/platypush/plugins/bluetooth/_legacy/_manager/_base.py b/platypush/plugins/bluetooth/_legacy/_manager/_base.py index 874950bd2..5376f6d69 100644 --- a/platypush/plugins/bluetooth/_legacy/_manager/_base.py +++ b/platypush/plugins/bluetooth/_legacy/_manager/_base.py @@ -10,8 +10,6 @@ from typing import ( Optional, Union, ) -from typing_extensions import override - import bluetooth from platypush.entities.bluetooth import BluetoothDevice, BluetoothService @@ -193,7 +191,6 @@ class LegacyManager(BaseBluetoothManager): conn.service.connected = False self.notify(BluetoothDeviceDisconnectedEvent, dev) - @override def connect( self, device: str, @@ -222,7 +219,6 @@ class LegacyManager(BaseBluetoothManager): conn_success = connected.wait(timeout=timeout) assert conn_success, f'Connection to {device} timed out' - @override def disconnect( self, device: str, @@ -241,7 +237,6 @@ class LegacyManager(BaseBluetoothManager): for conn in matching_connections: conn.close() - @override def scan(self, duration: Optional[float] = None) -> List[BluetoothDevice]: duration = duration or self.poll_interval assert duration, 'Scan duration must be set' @@ -301,7 +296,6 @@ class LegacyManager(BaseBluetoothManager): return list(devices.values()) - @override def read( self, device: str, @@ -321,7 +315,6 @@ class LegacyManager(BaseBluetoothManager): except bluetooth.BluetoothError as e: raise AssertionError(f'Error reading from {device}: {e}') from e - @override def write( self, device: str, @@ -338,7 +331,6 @@ class LegacyManager(BaseBluetoothManager): except bluetooth.BluetoothError as e: raise AssertionError(f'Error reading from {device}: {e}') from e - @override def run(self): super().run() self.logger.info('Starting legacy Bluetooth scanner') @@ -348,7 +340,6 @@ class LegacyManager(BaseBluetoothManager): if scan_enabled: self.scan(duration=self.poll_interval) - @override def stop(self): super().stop() diff --git a/platypush/plugins/bluetooth/_plugin.py b/platypush/plugins/bluetooth/_plugin.py index c4ee9badb..c9ea3be2d 100644 --- a/platypush/plugins/bluetooth/_plugin.py +++ b/platypush/plugins/bluetooth/_plugin.py @@ -15,8 +15,6 @@ from typing import ( Type, ) -from typing_extensions import override - from platypush.common import StoppableThread from platypush.context import get_bus, get_plugin from platypush.entities import ( @@ -479,7 +477,6 @@ class BluetoothPlugin(RunnablePlugin, EnumSwitchEntityManager): connect_timeout=connect_timeout, ) - @override @action def set(self, entity: str, value: Any, **_): """ @@ -549,7 +546,6 @@ class BluetoothPlugin(RunnablePlugin, EnumSwitchEntityManager): sender = FileSender(self._managers[LegacyManager]) # type: ignore sender.send_file(file, device, binary_data) - @override @action def status( self, @@ -608,13 +604,11 @@ class BluetoothPlugin(RunnablePlugin, EnumSwitchEntityManager): get_entities_engine().notify(*known_devices) return known_devices - @override def transform_entities( self, entities: Collection[BluetoothDevice] ) -> Collection[BluetoothDevice]: return super().transform_entities(entities) - @override def main(self): self._refresh_cache() self._init_bluetooth_managers() @@ -634,7 +628,6 @@ class BluetoothPlugin(RunnablePlugin, EnumSwitchEntityManager): finally: self.stop() - @override def stop(self): """ Upon stop request, it stops any pending scans and closes all active diff --git a/platypush/plugins/inspect/_parsers/_backend.py b/platypush/plugins/inspect/_parsers/_backend.py index 30f6eaa0f..1f84e8b7f 100644 --- a/platypush/plugins/inspect/_parsers/_backend.py +++ b/platypush/plugins/inspect/_parsers/_backend.py @@ -1,5 +1,4 @@ import re -from typing_extensions import override from ._base import Parser @@ -14,7 +13,6 @@ class BackendParser(Parser): r'(\s*):class:`(platypush\.backend\.(.+?))`', re.MULTILINE ) - @override @classmethod def parse(cls, docstring: str, *_, **__) -> str: while True: diff --git a/platypush/plugins/inspect/_parsers/_event.py b/platypush/plugins/inspect/_parsers/_event.py index ffdf4b8c5..ebe4ba522 100644 --- a/platypush/plugins/inspect/_parsers/_event.py +++ b/platypush/plugins/inspect/_parsers/_event.py @@ -1,5 +1,4 @@ import re -from typing_extensions import override from ._base import Parser @@ -14,7 +13,6 @@ class EventParser(Parser): r'(\s*):class:`(platypush\.message\.event\.(.+?))`', re.MULTILINE ) - @override @classmethod def parse(cls, docstring: str, *_, **__) -> str: while True: diff --git a/platypush/plugins/inspect/_parsers/_method.py b/platypush/plugins/inspect/_parsers/_method.py index 619b2fd8c..ae2a29fef 100644 --- a/platypush/plugins/inspect/_parsers/_method.py +++ b/platypush/plugins/inspect/_parsers/_method.py @@ -1,5 +1,4 @@ import re -from typing_extensions import override from ._base import Parser @@ -16,7 +15,6 @@ class MethodParser(Parser): _rel_method_regex = re.compile(r'(\s*):meth:`\.(.+?)`', re.MULTILINE) - @override @classmethod def parse(cls, docstring: str, obj_type: type) -> str: while True: diff --git a/platypush/plugins/inspect/_parsers/_plugin.py b/platypush/plugins/inspect/_parsers/_plugin.py index e78920da5..51f0550d3 100644 --- a/platypush/plugins/inspect/_parsers/_plugin.py +++ b/platypush/plugins/inspect/_parsers/_plugin.py @@ -1,5 +1,4 @@ import re -from typing_extensions import override from ._base import Parser @@ -14,7 +13,6 @@ class PluginParser(Parser): r'(\s*):class:`(platypush\.plugins\.(.+?))`', re.MULTILINE ) - @override @classmethod def parse(cls, docstring: str, *_, **__) -> str: while True: diff --git a/platypush/plugins/inspect/_parsers/_response.py b/platypush/plugins/inspect/_parsers/_response.py index a6cdf68da..2f055ff73 100644 --- a/platypush/plugins/inspect/_parsers/_response.py +++ b/platypush/plugins/inspect/_parsers/_response.py @@ -1,5 +1,4 @@ import re -from typing_extensions import override from ._base import Parser @@ -14,7 +13,6 @@ class ResponseParser(Parser): r'(\s*):class:`(platypush\.message\.response\.(.+?))`', re.MULTILINE ) - @override @classmethod def parse(cls, docstring: str, *_, **__) -> str: while True: diff --git a/platypush/plugins/inspect/_parsers/_schema.py b/platypush/plugins/inspect/_parsers/_schema.py index f7da97527..9913dcd43 100644 --- a/platypush/plugins/inspect/_parsers/_schema.py +++ b/platypush/plugins/inspect/_parsers/_schema.py @@ -5,7 +5,6 @@ import os from random import randint import re import textwrap -from typing_extensions import override from marshmallow import fields @@ -59,7 +58,6 @@ class SchemaParser(Parser): return str(field.__class__.__name__).lower() - @override @classmethod def parse(cls, docstring: str, *_, **__) -> str: while True: diff --git a/platypush/plugins/linode/__init__.py b/platypush/plugins/linode/__init__.py index ff2a48762..dbc371287 100644 --- a/platypush/plugins/linode/__init__.py +++ b/platypush/plugins/linode/__init__.py @@ -1,7 +1,5 @@ from typing import Collection, List, Optional -from typing_extensions import override - from linode_api4 import LinodeClient, Instance, objects from platypush.context import get_bus @@ -88,7 +86,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM if not key.startswith('_') } - @override def main(self): instances = [] @@ -133,7 +130,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM instances = new_status.values() self.wait_stop(self.poll_interval) - @override def transform_entities( self, entities: Collection[LinodeInstance] ) -> Collection[CloudInstance]: @@ -157,7 +153,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM ) @action - @override def status( self, *_, @@ -196,7 +191,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM return mapped_instances - @override @action def reboot(self, instance: InstanceId, token: Optional[str] = None, **_): """ @@ -208,7 +202,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM node = self._get_instance(instance=instance, token=token) assert node.reboot(), 'Reboot failed' - @override @action def boot(self, instance: InstanceId, token: Optional[str] = None, **_): """ @@ -220,7 +213,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM node = self._get_instance(instance=instance, token=token) assert node.boot(), 'Boot failed' - @override @action def shutdown(self, instance: InstanceId, token: Optional[str] = None, **_): """ @@ -232,7 +224,6 @@ class LinodePlugin(RunnablePlugin, CloudInstanceEntityManager, EnumSwitchEntityM node = self._get_instance(instance=instance, token=token) assert node.shutdown(), 'Shutdown failed' - @override @action def set(self, entity: str, value: str, **kwargs): """ diff --git a/platypush/plugins/mqtt/__init__.py b/platypush/plugins/mqtt/__init__.py index ac9e22a17..a43c03773 100644 --- a/platypush/plugins/mqtt/__init__.py +++ b/platypush/plugins/mqtt/__init__.py @@ -4,7 +4,6 @@ import io import json import threading from typing import Any, Dict, Iterable, Optional, IO -from typing_extensions import override import paho.mqtt.client as mqtt @@ -504,7 +503,6 @@ class MqttPlugin(RunnablePlugin): """ return self.publish(*args, **kwargs) - @override def main(self): if self.run_topic: self.logger.warning( @@ -519,7 +517,6 @@ class MqttPlugin(RunnablePlugin): self.wait_stop() - @override def stop(self): """ Disconnect all the clients upon plugin stop. diff --git a/platypush/plugins/sensor/__init__.py b/platypush/plugins/sensor/__init__.py index 775ac9998..c0559709e 100644 --- a/platypush/plugins/sensor/__init__.py +++ b/platypush/plugins/sensor/__init__.py @@ -1,6 +1,5 @@ from abc import ABC, abstractmethod from typing import Collection, Iterable, List, Mapping, Optional, Tuple, Type, Union -from typing_extensions import override from platypush.common.sensors import Numeric, SensorDataType from platypush.context import get_bus @@ -327,12 +326,10 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC): return {k: v for k, v in data.items() if k in self._enabled_sensors} - @override @abstractmethod def transform_entities(self, entities: SensorDataType) -> Collection[Entity]: raise NotImplementedError() - @override def publish_entities( self, entities: SensorDataType, *args, **kwargs ) -> Collection[Entity]: @@ -393,7 +390,6 @@ class SensorPlugin(RunnablePlugin, SensorEntityManager, ABC): self.publish_entities(self._last_measurement) return self._last_measurement - @override def main(self): sleep_retry_secs = 1 # Exponential back-off diff --git a/platypush/plugins/sensor/bme280/__init__.py b/platypush/plugins/sensor/bme280/__init__.py index 724a093ef..cf81f2c79 100644 --- a/platypush/plugins/sensor/bme280/__init__.py +++ b/platypush/plugins/sensor/bme280/__init__.py @@ -1,6 +1,5 @@ from dataclasses import dataclass from typing import Dict, List, Type -from typing_extensions import override from platypush.common.sensors import Numeric from platypush.entities.devices import Device @@ -98,7 +97,6 @@ class SensorBme280Plugin(SensorPlugin): self._device = BME280(i2c_dev=self._bus) return self._device - @override @action def get_measurement(self, *_, **__): """ @@ -123,7 +121,6 @@ class SensorBme280Plugin(SensorPlugin): 'altitude': device.get_altitude(), } - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: sensors = [] for sensor, value in entities.items(): diff --git a/platypush/plugins/sensor/dht/__init__.py b/platypush/plugins/sensor/dht/__init__.py index 041b8ff4e..a5f9d642b 100644 --- a/platypush/plugins/sensor/dht/__init__.py +++ b/platypush/plugins/sensor/dht/__init__.py @@ -1,8 +1,7 @@ from typing import List, Optional, Dict -from typing_extensions import override + from platypush.common.sensors import Numeric from platypush.entities.devices import Device - from platypush.entities.humidity import HumiditySensor from platypush.entities.temperature import TemperatureSensor from platypush.plugins import action @@ -101,7 +100,6 @@ class SensorDhtPlugin(SensorPlugin): 'temperature': temperature, } - @override @action def get_measurement(self, *_, **__) -> Dict[str, float]: """ @@ -119,7 +117,6 @@ class SensorDhtPlugin(SensorPlugin): """ return self.read() # type: ignore - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: return [ Device( diff --git a/platypush/plugins/sensor/distance/vl53l1x/__init__.py b/platypush/plugins/sensor/distance/vl53l1x/__init__.py index 1060a2a88..0fc373bfd 100644 --- a/platypush/plugins/sensor/distance/vl53l1x/__init__.py +++ b/platypush/plugins/sensor/distance/vl53l1x/__init__.py @@ -1,7 +1,6 @@ from contextlib import contextmanager from threading import RLock from typing import List, Mapping -from typing_extensions import override from platypush.entities.devices import Device from platypush.entities.distance import DistanceSensor @@ -65,7 +64,6 @@ class SensorDistanceVl53l1xPlugin(SensorPlugin): self._device.close() self._device = None - @override def get_measurement(self, *_, short=True, medium=True, long=True, **__): """ :param short: Enable short range measurement (default: True) @@ -109,7 +107,6 @@ class SensorDistanceVl53l1xPlugin(SensorPlugin): return ret - @override def transform_entities(self, entities: Mapping[str, int]) -> List[Device]: return [ Device( diff --git a/platypush/plugins/sensor/envirophat/__init__.py b/platypush/plugins/sensor/envirophat/__init__.py index 33c22cdd1..366a8ae3c 100644 --- a/platypush/plugins/sensor/envirophat/__init__.py +++ b/platypush/plugins/sensor/envirophat/__init__.py @@ -1,6 +1,5 @@ from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Type -from typing_extensions import override from platypush.common.sensors import Numeric from platypush.entities.acceleration import Accelerometer @@ -99,7 +98,6 @@ class SensorEnvirophatPlugin(SensorPlugin): """ - @override @action def get_measurement(self, *_, qnh: float = 1020.0, **__): """ @@ -156,7 +154,6 @@ class SensorEnvirophatPlugin(SensorPlugin): return ret - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: return [ Device( diff --git a/platypush/plugins/sensor/hcsr04/__init__.py b/platypush/plugins/sensor/hcsr04/__init__.py index 73dc3e2c5..2f69586cb 100644 --- a/platypush/plugins/sensor/hcsr04/__init__.py +++ b/platypush/plugins/sensor/hcsr04/__init__.py @@ -1,8 +1,6 @@ from collections.abc import Collection import time - from typing import List, Optional, Union -from typing_extensions import override import warnings from platypush.context import get_bus @@ -142,7 +140,6 @@ class SensorHcsr04Plugin(GpioPlugin, SensorPlugin): # s = vt where v = 1/2 * avg speed of sound in mm/s return round(pulse_duration * 171500.0, 2) - @override @action def get_measurement(self, *_, **__) -> Optional[float]: """ @@ -161,7 +158,6 @@ class SensorHcsr04Plugin(GpioPlugin, SensorPlugin): self.cleanup() raise e - @override def transform_entities( self, entities: Union[Optional[float], Collection[Optional[float]]] ) -> List[DistanceSensor]: diff --git a/platypush/plugins/sensor/lis3dh/__init__.py b/platypush/plugins/sensor/lis3dh/__init__.py index eb519a52a..aee045c1c 100644 --- a/platypush/plugins/sensor/lis3dh/__init__.py +++ b/platypush/plugins/sensor/lis3dh/__init__.py @@ -1,5 +1,4 @@ from typing import Any, Dict, List -from typing_extensions import override from platypush.entities.acceleration import Accelerometer from platypush.plugins import action @@ -56,7 +55,6 @@ class SensorLis3dhPlugin(SensorPlugin): self.sensor = LIS3DH() self.sensor.setRange(self.g) - @override @action def get_measurement(self, *_, **__): """ @@ -74,7 +72,6 @@ class SensorLis3dhPlugin(SensorPlugin): 'value': {'x': values[0], 'y': values[1], 'z': values[2]}, } - @override def transform_entities(self, entities: Dict[str, Any]) -> List[Accelerometer]: return Accelerometer( id='lis3dh', diff --git a/platypush/plugins/sensor/ltr559/__init__.py b/platypush/plugins/sensor/ltr559/__init__.py index 35befb6f1..b0280da0a 100644 --- a/platypush/plugins/sensor/ltr559/__init__.py +++ b/platypush/plugins/sensor/ltr559/__init__.py @@ -1,7 +1,5 @@ from typing import Dict, List -from typing_extensions import override - from platypush.common.sensors import Numeric from platypush.entities.devices import Device from platypush.entities.distance import DistanceSensor @@ -35,7 +33,6 @@ class SensorLtr559Plugin(SensorPlugin): super().__init__(**kwargs) self.ltr = ltr559.LTR559() - @override @action def get_measurement(self, *_, **__): """ @@ -55,7 +52,6 @@ class SensorLtr559Plugin(SensorPlugin): 'proximity': self.ltr.get_proximity(), } - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: sensors = [] diff --git a/platypush/plugins/sensor/mcp3008/__init__.py b/platypush/plugins/sensor/mcp3008/__init__.py index dcc97fb71..c6f4443e6 100644 --- a/platypush/plugins/sensor/mcp3008/__init__.py +++ b/platypush/plugins/sensor/mcp3008/__init__.py @@ -1,6 +1,5 @@ import enum from typing import Dict, List -from typing_extensions import override from platypush.common.sensors import Numeric from platypush.entities.devices import Device @@ -154,7 +153,6 @@ class SensorMcp3008Plugin(SensorPlugin): def _convert_to_voltage(self, value): return (value * self.Vdd) / 1023.0 if value is not None else None - @override @action def get_measurement(self): """ @@ -197,7 +195,6 @@ class SensorMcp3008Plugin(SensorPlugin): return values - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: return [ Device( diff --git a/platypush/plugins/sensor/pmw3901/__init__.py b/platypush/plugins/sensor/pmw3901/__init__.py index b32936016..d566de51b 100644 --- a/platypush/plugins/sensor/pmw3901/__init__.py +++ b/platypush/plugins/sensor/pmw3901/__init__.py @@ -2,7 +2,6 @@ import enum import math import time from typing import Dict, List -from typing_extensions import override from platypush.common.sensors import Numeric from platypush.entities.devices import Device @@ -114,7 +113,6 @@ class SensorPmw3901Plugin(SensorPlugin): return self._sensor - @override @action def get_measurement(self, *_, **__): """ @@ -156,7 +154,6 @@ class SensorPmw3901Plugin(SensorPlugin): 'motion_events_per_sec': self._events_per_sec.get(secs, 0), } - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: return [ Device( diff --git a/platypush/plugins/serial/__init__.py b/platypush/plugins/serial/__init__.py index d4811eec4..69d20f0aa 100644 --- a/platypush/plugins/serial/__init__.py +++ b/platypush/plugins/serial/__init__.py @@ -3,7 +3,6 @@ from collections import namedtuple import json from typing import Dict, List, Optional, Union import threading -from typing_extensions import override from serial import Serial @@ -258,7 +257,6 @@ class SerialPlugin(SensorPlugin): return _DeviceAndRate(device, baud_rate) - @override @action def get_measurement( self, @@ -386,7 +384,6 @@ class SerialPlugin(SensorPlugin): self.logger.info('Writing %d bytes to %s', len(data), device) ser.write(data) - @override def transform_entities(self, entities: Dict[str, Numeric]) -> List[Device]: transformed_entities = [] @@ -415,7 +412,6 @@ class SerialPlugin(SensorPlugin): ) ] - @override def main(self): if not self._enable_polling: # If the polling is disabled, we don't need to do anything here @@ -424,7 +420,6 @@ class SerialPlugin(SensorPlugin): super().main() - @override def stop(self): super().stop() self._close_serial() diff --git a/platypush/plugins/sound/__init__.py b/platypush/plugins/sound/__init__.py index 88f432e09..5d158dc6d 100644 --- a/platypush/plugins/sound/__init__.py +++ b/platypush/plugins/sound/__init__.py @@ -1,7 +1,6 @@ from dataclasses import asdict import warnings from typing import Iterable, List, Optional, Union -from typing_extensions import override from platypush.plugins import RunnablePlugin, action @@ -471,7 +470,6 @@ class SoundPlugin(RunnablePlugin): """ self._manager.set_volume(volume=volume, device=device, streams=streams) - @override def main(self): try: self.wait_stop() diff --git a/platypush/plugins/sound/_converters/_from_raw.py b/platypush/plugins/sound/_converters/_from_raw.py index 09c21c184..f67f94de7 100644 --- a/platypush/plugins/sound/_converters/_from_raw.py +++ b/platypush/plugins/sound/_converters/_from_raw.py @@ -1,5 +1,4 @@ from typing import Iterable -from typing_extensions import override from ._base import AudioConverter @@ -10,12 +9,10 @@ class RawInputAudioConverter(AudioConverter): """ @property - @override def _input_format_args(self) -> Iterable[str]: return self._raw_ffmpeg_args @property - @override def _output_format_args(self) -> Iterable[str]: return self._compressed_ffmpeg_args diff --git a/platypush/plugins/sound/_converters/_to_raw.py b/platypush/plugins/sound/_converters/_to_raw.py index 1263683ad..024256af1 100644 --- a/platypush/plugins/sound/_converters/_to_raw.py +++ b/platypush/plugins/sound/_converters/_to_raw.py @@ -1,5 +1,4 @@ from typing import Iterable -from typing_extensions import override from ._base import AudioConverter @@ -10,12 +9,10 @@ class RawOutputAudioConverter(AudioConverter): """ @property - @override def _input_format_args(self) -> Iterable[str]: return self._compressed_ffmpeg_args @property - @override def _output_format_args(self) -> Iterable[str]: return self._raw_ffmpeg_args @@ -30,7 +27,6 @@ class RawOutputAudioFromFileConverter(RawOutputAudioConverter): self.infile = infile @property - @override def _input_source_args(self) -> Iterable[str]: return ('-i', self.infile) diff --git a/platypush/plugins/sound/_streams/_base.py b/platypush/plugins/sound/_streams/_base.py index 7a55eb2c2..6c369fe54 100644 --- a/platypush/plugins/sound/_streams/_base.py +++ b/platypush/plugins/sound/_streams/_base.py @@ -7,7 +7,6 @@ import queue from threading import Event, RLock, Thread import time from typing import IO, Callable, Final, Generator, Optional, Tuple, Type, Union -from typing_extensions import override import sounddevice as sd @@ -326,7 +325,6 @@ class AudioThread(Thread, ABC): # Continue only if the converter hasn't terminated return not self._converter_terminated.is_set() - @override def run(self): """ Wrapper for the main loop that initializes the converter and the stream. diff --git a/platypush/plugins/sound/_streams/_player/_base.py b/platypush/plugins/sound/_streams/_player/_base.py index 6b4a12212..a3aab707f 100644 --- a/platypush/plugins/sound/_streams/_player/_base.py +++ b/platypush/plugins/sound/_streams/_player/_base.py @@ -1,6 +1,5 @@ from abc import ABC from typing import IO, Iterable, List, Optional, Type, Union -from typing_extensions import override import numpy as np import sounddevice as sd @@ -55,25 +54,20 @@ class AudioPlayer(AudioThread, ABC): raise AssertionError('Either infile or url must be specified') @property - @override def direction(self) -> StreamType: return StreamType.OUTPUT - @override def _on_converter_timeout(self, *_, **__) -> bool: return False # break @property - @override def _stream_type(self) -> Type[sd.RawOutputStream]: return sd.RawOutputStream @property - @override def _audio_converter_type(self) -> Type[RawOutputAudioConverter]: return RawOutputAudioConverter - @override def _on_audio_converted(self, data: bytes, out_f: Optional[IO] = None): if self.audio_stream: self.audio_stream.write( @@ -87,22 +81,18 @@ class AudioPlayer(AudioThread, ABC): super()._on_audio_converted(data, out_f) @property - @override def _started_event_type(self) -> Type[SoundPlaybackStartedEvent]: return SoundPlaybackStartedEvent @property - @override def _stopped_event_type(self) -> Type[SoundPlaybackStoppedEvent]: return SoundPlaybackStoppedEvent @property - @override def _paused_event_type(self) -> Type[SoundPlaybackPausedEvent]: return SoundPlaybackPausedEvent @property - @override def _resumed_event_type(self) -> Type[SoundPlaybackResumedEvent]: return SoundPlaybackResumedEvent diff --git a/platypush/plugins/sound/_streams/_player/_resource.py b/platypush/plugins/sound/_streams/_player/_resource.py index f58ed91a9..5186d5e79 100644 --- a/platypush/plugins/sound/_streams/_player/_resource.py +++ b/platypush/plugins/sound/_streams/_player/_resource.py @@ -1,5 +1,4 @@ from typing import Optional, Type -from typing_extensions import override from platypush.message.event.sound import SoundEvent @@ -14,12 +13,10 @@ class AudioResourcePlayer(AudioPlayer): """ @property - @override def _audio_converter_type(self) -> Type[RawOutputAudioFromFileConverter]: return RawOutputAudioFromFileConverter @property - @override def _converter_args(self) -> dict: return { 'infile': self.infile, @@ -27,11 +24,9 @@ class AudioResourcePlayer(AudioPlayer): } @property - @override def _converter_stdin(self) -> Optional[int]: return None - @override def _notify(self, event_type: Type[SoundEvent], **kwargs): return super()._notify(event_type, resource=self.infile, **kwargs) diff --git a/platypush/plugins/sound/_streams/_player/_synth/_mix.py b/platypush/plugins/sound/_streams/_player/_synth/_mix.py index c7d09a419..957a20848 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_mix.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_mix.py @@ -1,7 +1,6 @@ import json import logging from typing import List, Tuple, Union -from typing_extensions import override import numpy as np from numpy.typing import DTypeLike, NDArray @@ -57,7 +56,6 @@ class Mix(SoundBase): for sound_index in sound_indices[::-1]: self._sounds.pop(sound_index) - @override def get_wave( self, sample_rate: float, diff --git a/platypush/plugins/sound/_streams/_player/_synth/_player.py b/platypush/plugins/sound/_streams/_player/_synth/_player.py index dde23caf0..c0d6b1099 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_player.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_player.py @@ -2,7 +2,6 @@ from contextlib import contextmanager from queue import Queue from threading import Event from typing import Any, Generator, Iterable, Optional, Type -from typing_extensions import override import numpy as np import sounddevice as sd @@ -42,12 +41,10 @@ class AudioSynthPlayer(AudioPlayer): ) @property - @override def _stream_type(self) -> Type[sd.OutputStream]: return sd.OutputStream @property - @override def _audio_converter_type(self) -> None: pass @@ -61,7 +58,6 @@ class AudioSynthPlayer(AudioPlayer): self.mix.volume = __value return super().__setattr__(__name, __value) - @override def _on_converter_timeout(self, *_, **__) -> bool: """ Don't break the audio stream if the output converter failed @@ -69,7 +65,6 @@ class AudioSynthPlayer(AudioPlayer): return True @property - @override def _stream_args(self) -> dict: """ Register an :class:`.AudioOutputCallback` to fill up the audio buffers. @@ -95,7 +90,6 @@ class AudioSynthPlayer(AudioPlayer): """ return self.blocksize * (self.queue_size or 5) / self.sample_rate - @override @contextmanager def _audio_generator(self) -> Generator[AudioGenerator, None, None]: stop_generator = Event() diff --git a/platypush/plugins/sound/_streams/_player/_synth/_sound.py b/platypush/plugins/sound/_streams/_player/_synth/_sound.py index 1edc401ad..270dcc5b6 100644 --- a/platypush/plugins/sound/_streams/_player/_synth/_sound.py +++ b/platypush/plugins/sound/_streams/_player/_synth/_sound.py @@ -1,7 +1,6 @@ from enum import Enum import json from typing import Final, Optional, Tuple, Union -from typing_extensions import override import numpy as np from numpy.typing import NDArray @@ -144,7 +143,6 @@ class Sound(SoundBase): return wave - @override def get_wave( self, sample_rate: float, diff --git a/platypush/plugins/sound/_streams/_recorder.py b/platypush/plugins/sound/_streams/_recorder.py index d5c560caa..abec81da1 100644 --- a/platypush/plugins/sound/_streams/_recorder.py +++ b/platypush/plugins/sound/_streams/_recorder.py @@ -1,5 +1,4 @@ from typing import Type -from typing_extensions import override import sounddevice as sd @@ -27,11 +26,9 @@ class AudioRecorder(AudioThread): self.output_format = output_format @property - @override def direction(self) -> StreamType: return StreamType.INPUT - @override def _audio_callback(self): # _ = frames # __ = time @@ -62,32 +59,26 @@ class AudioRecorder(AudioThread): return callback @property - @override def _audio_converter_type(self) -> Type[RawInputAudioConverter]: return RawInputAudioConverter @property - @override def _started_event_type(self) -> Type[SoundRecordingStartedEvent]: return SoundRecordingStartedEvent @property - @override def _stopped_event_type(self) -> Type[SoundRecordingStoppedEvent]: return SoundRecordingStoppedEvent @property - @override def _paused_event_type(self) -> Type[SoundRecordingPausedEvent]: return SoundRecordingPausedEvent @property - @override def _resumed_event_type(self) -> Type[SoundRecordingResumedEvent]: return SoundRecordingResumedEvent @property - @override def _converter_args(self) -> dict: return { 'format': self.output_format, @@ -95,7 +86,6 @@ class AudioRecorder(AudioThread): } @property - @override def _stream_args(self) -> dict: return { 'callback': self._audio_callback(), diff --git a/platypush/plugins/system/__init__.py b/platypush/plugins/system/__init__.py index de0b90dc9..099790edb 100644 --- a/platypush/plugins/system/__init__.py +++ b/platypush/plugins/system/__init__.py @@ -1,7 +1,5 @@ import os - from typing import Tuple, Union, List, Optional -from typing_extensions import override import psutil @@ -506,7 +504,6 @@ class SystemPlugin(SensorPlugin, EntityManager): """ self._get_process(pid).wait(timeout) - @override @action def get_measurement(self, *_, **__): """ @@ -532,7 +529,6 @@ class SystemPlugin(SensorPlugin, EntityManager): } ) - @override def transform_entities(self, entities: dict) -> List[Entity]: cpu = entities['cpu'].copy() battery = entities['battery'] diff --git a/platypush/plugins/variable/__init__.py b/platypush/plugins/variable/__init__.py index 5c4f26595..e1c451c4a 100644 --- a/platypush/plugins/variable/__init__.py +++ b/platypush/plugins/variable/__init__.py @@ -1,7 +1,6 @@ from functools import wraps from threading import Event, RLock from typing import Any, Callable, Collection, Dict, Iterable, Optional, Union -from typing_extensions import override from platypush.entities import EntityManager, get_entities_engine from platypush.entities.variables import Variable @@ -170,7 +169,6 @@ class VariablePlugin(Plugin, EntityManager): return self._redis.expire(name, expire) - @override def transform_entities( self, entities: Union[dict, Iterable] ) -> Collection[Variable]: @@ -193,7 +191,6 @@ class VariablePlugin(Plugin, EntityManager): ] ) - @override @action @ensure_initialized def status(self, *_, **__): diff --git a/platypush/plugins/xmpp/__init__.py b/platypush/plugins/xmpp/__init__.py index a7de00766..15a9458eb 100644 --- a/platypush/plugins/xmpp/__init__.py +++ b/platypush/plugins/xmpp/__init__.py @@ -1,6 +1,5 @@ import os from typing import Iterable, Optional, Type, Union -from typing_extensions import override import aioxmpp import aioxmpp.im @@ -177,11 +176,9 @@ class XmppPlugin(AsyncRunnablePlugin, XmppBasePlugin): return self._handlers[hndl_type] - @override def should_stop(self) -> bool: return super().should_stop() or self._state.should_stop.is_set() - @override def stop(self): self._state.should_stop.set() self._stop_state_serializer() @@ -199,7 +196,6 @@ class XmppPlugin(AsyncRunnablePlugin, XmppBasePlugin): self._client.stop() self._client = None - @override async def listen(self): self._client = aioxmpp.PresenceManagedClient(self._jid, self._security) diff --git a/platypush/plugins/xmpp/_handlers/_registry.py b/platypush/plugins/xmpp/_handlers/_registry.py index 300798954..7c26c690f 100644 --- a/platypush/plugins/xmpp/_handlers/_registry.py +++ b/platypush/plugins/xmpp/_handlers/_registry.py @@ -1,6 +1,5 @@ from collections import defaultdict from typing import Type -from typing_extensions import override from .._base import XmppBasePlugin from ._base import XmppBaseHandler @@ -15,6 +14,5 @@ class XmppHandlersRegistry(defaultdict): super().__init__() self._plugin = plugin - @override def __missing__(self, hndl_type: Type[XmppBaseHandler]) -> XmppBaseHandler: return self._plugin.register_handler(hndl_type) diff --git a/platypush/plugins/xmpp/_handlers/_room.py b/platypush/plugins/xmpp/_handlers/_room.py index 5858c0c56..093eafe1d 100644 --- a/platypush/plugins/xmpp/_handlers/_room.py +++ b/platypush/plugins/xmpp/_handlers/_room.py @@ -1,6 +1,5 @@ import asyncio from typing import Iterable, Optional, Union -from typing_extensions import override import aioxmpp import aioxmpp.im @@ -49,7 +48,6 @@ class XmppRoomHandler(XmppBaseHandler): ] ) - @override def restore_state(self): self._async_run(self._restore_state, wait_result=False) diff --git a/platypush/plugins/xmpp/_handlers/_roster.py b/platypush/plugins/xmpp/_handlers/_roster.py index 1b4498cb0..cf70491f2 100644 --- a/platypush/plugins/xmpp/_handlers/_roster.py +++ b/platypush/plugins/xmpp/_handlers/_roster.py @@ -1,5 +1,5 @@ from typing import Union -from typing_extensions import override + import aioxmpp import aioxmpp.roster.xso @@ -28,7 +28,6 @@ class XmppRosterHandler(XmppBaseHandler): self.roster.on_entry_removed.connect(self._on_roster_entry_removed) # type: ignore self.roster.on_subscribe.connect(self._on_roster_subscribe) # type: ignore - @override def restore_state(self): if self._loaded_state.users: for user_id in self._loaded_state.users: diff --git a/platypush/plugins/xmpp/_mixins/_event_state.py b/platypush/plugins/xmpp/_mixins/_event_state.py index 29080c13f..d434ea386 100644 --- a/platypush/plugins/xmpp/_mixins/_event_state.py +++ b/platypush/plugins/xmpp/_mixins/_event_state.py @@ -1,5 +1,4 @@ from abc import ABC -from typing_extensions import override from ._events import XmppEventMixin from ._state import XmppStateMixin @@ -12,7 +11,6 @@ class XmppEventStateMixin(XmppEventMixin, XmppStateMixin, ABC): features to handle events. """ - @override def _post_event(self, *args, **kwargs): if self._state_serializer: self._state_serializer.enqueue(self._state) diff --git a/platypush/plugins/zigbee/mqtt/__init__.py b/platypush/plugins/zigbee/mqtt/__init__.py index 027c3c006..24da49b73 100644 --- a/platypush/plugins/zigbee/mqtt/__init__.py +++ b/platypush/plugins/zigbee/mqtt/__init__.py @@ -15,7 +15,6 @@ from typing import ( Type, Union, ) -from typing_extensions import override import paho.mqtt.client as mqtt @@ -313,7 +312,6 @@ class ZigbeeMqttPlugin( if option.get('property') } - @override def transform_entities(self, entities: Collection[dict]) -> List[Entity]: compatible_entities = [] for dev in entities: @@ -1222,7 +1220,6 @@ class ZigbeeMqttPlugin( self.device_set(dev, property, data, **kwargs) - @override @action def set(self, entity: str, value: Any, attribute: Optional[str] = None, **kwargs): return self.set_value(entity, data=value, property=attribute, **kwargs) @@ -2136,7 +2133,6 @@ class ZigbeeMqttPlugin( self.device_set(self._preferred_name(dev), values=data) - @override def on_mqtt_message(self): """ Overrides :meth:`platypush.plugins.mqtt.MqttPlugin.on_mqtt_message` to diff --git a/platypush/plugins/zwave/mqtt/__init__.py b/platypush/plugins/zwave/mqtt/__init__.py index 77ad17445..47e729b46 100644 --- a/platypush/plugins/zwave/mqtt/__init__.py +++ b/platypush/plugins/zwave/mqtt/__init__.py @@ -21,8 +21,6 @@ from typing import ( ) from urllib.parse import parse_qs, urlparse -from typing_extensions import override - from platypush.entities import ( DimmerEntityManager, EnumSwitchEntityManager, @@ -958,7 +956,6 @@ class ZwaveMqttPlugin( assert group_id in groups, f'No such group_id: {group_id}' return groups[group_id] - @override def on_mqtt_message(self): def handler(_, __, msg): if not msg.topic.startswith(self.events_topic): @@ -2189,7 +2186,6 @@ class ZwaveMqttPlugin( 'id': value['value_id'], } - @override def main(self): self.get_nodes() super().main() diff --git a/platypush/process/__init__.py b/platypush/process/__init__.py index 582a8e7f6..66ff1ae99 100644 --- a/platypush/process/__init__.py +++ b/platypush/process/__init__.py @@ -3,7 +3,6 @@ import logging from multiprocessing import Event, Process, RLock from os import getpid from typing import Optional -from typing_extensions import override class ControllableProcess(Process, ABC): @@ -121,7 +120,6 @@ class ControllableProcess(Process, ABC): self._should_restart = False return self.main() - @override def run(self) -> None: """ Executes the process. diff --git a/platypush/runner/_app.py b/platypush/runner/_app.py index 718780e76..a0a147764 100644 --- a/platypush/runner/_app.py +++ b/platypush/runner/_app.py @@ -3,7 +3,6 @@ import os import signal import subprocess import sys -from typing_extensions import override from platypush.process import ControllableProcess @@ -27,7 +26,6 @@ class ApplicationProcess(ControllableProcess): def __exit__(self, *_, **__): self.stop() - @override def main(self): self.logger.info('Starting application...') @@ -42,7 +40,6 @@ class ApplicationProcess(ControllableProcess): except KeyboardInterrupt: pass - @override def on_stop(self): try: with open(self.pidfile, 'r') as f: diff --git a/platypush/utils/manifest.py b/platypush/utils/manifest.py index b5f6c39b2..421fead48 100644 --- a/platypush/utils/manifest.py +++ b/platypush/utils/manifest.py @@ -25,7 +25,6 @@ from typing import ( Type, Union, ) -from typing_extensions import override import yaml @@ -551,7 +550,6 @@ class PluginManifest(Manifest): """ @property - @override def manifest_type(self) -> ManifestType: return ManifestType.PLUGIN @@ -563,7 +561,6 @@ class BackendManifest(Manifest): """ @property - @override def manifest_type(self) -> ManifestType: return ManifestType.BACKEND