upgrade code to python 3.10

This commit is contained in:
Robert Resch 2022-04-08 23:14:59 +02:00
parent 0738a30ad5
commit 1d0b0e3deb
5 changed files with 7 additions and 7 deletions

View file

@ -9,7 +9,7 @@ repos:
rev: v2.31.1 rev: v2.31.1
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py39-plus] args: [--py310-plus]
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 22.3.0
hooks: hooks:

View file

@ -19,9 +19,9 @@ class CommandDto:
def __init__(self, payload_type: str) -> None: def __init__(self, payload_type: str) -> None:
self._payload_type = payload_type self._payload_type = payload_type
self._event = asyncio.Event() self._event = asyncio.Event()
self._response: Union[str, bytes] self._response: str | bytes
async def wait_for_response(self) -> Union[str, dict[str, Any]]: async def wait_for_response(self) -> str | dict[str, Any]:
"""Wait for the response to be received.""" """Wait for the response to be received."""
await self._event.wait() await self._event.wait()
if self._payload_type == "j": if self._payload_type == "j":
@ -29,7 +29,7 @@ class CommandDto:
return str(self._response) return str(self._response)
def add_response(self, response: Union[str, bytes]) -> None: def add_response(self, response: str | bytes) -> None:
"""Add received response.""" """Add received response."""
self._response = response self._response = response
self._event.set() self._event.set()

View file

@ -46,7 +46,7 @@ def get_logger(name: str, rotate: RotatingFileHandler = None) -> logging.Logger:
return logger return logger
def convert_to_millis(seconds: Union[int, float]) -> int: def convert_to_millis(seconds: int | float) -> int:
"""Convert seconds to milliseconds.""" """Convert seconds to milliseconds."""
return int(round(seconds * 1000)) return int(round(seconds * 1000))

View file

@ -58,7 +58,7 @@ class WebServer:
_EXCLUDE_FROM_LOGGING = ["base", "remove-bot", "remove-client", "restart-service"] _EXCLUDE_FROM_LOGGING = ["base", "remove-bot", "remove-client", "restart-service"]
def __init__(self, bindings: Union[list[WebserverBinding], WebserverBinding]): def __init__(self, bindings: list[WebserverBinding] | WebserverBinding):
self._runners: list[web.AppRunner] = [] self._runners: list[web.AppRunner] = []
if isinstance(bindings, WebserverBinding): if isinstance(bindings, WebserverBinding):

View file

@ -1,5 +1,5 @@
[mypy] [mypy]
python_version = 3.9 python_version = 3.10
show_error_codes = true show_error_codes = true
follow_imports = silent follow_imports = silent
ignore_missing_imports = true ignore_missing_imports = true