run pyupgrade for python3.9

This commit is contained in:
Robert Resch 2022-02-11 22:22:38 +01:00
parent f8045c3be5
commit a6593df48a
3 changed files with 13 additions and 13 deletions

View file

@ -9,9 +9,9 @@ repos:
rev: v2.31.0 rev: v2.31.0
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py37-plus] args: [--py39-plus]
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.12b0 rev: 22.1.0
hooks: hooks:
- id: black - id: black
args: args:
@ -38,7 +38,7 @@ repos:
<<: &python-files <<: &python-files
files: ^(bumper/.+)?[^/]+\.py$ files: ^(bumper/.+)?[^/]+\.py$
- repo: https://github.com/PyCQA/bandit - repo: https://github.com/PyCQA/bandit
rev: 1.7.1 rev: 1.7.2
hooks: hooks:
- id: bandit - id: bandit
args: args:

View file

@ -122,7 +122,7 @@ class OAuth:
return data return data
def include_EcoVacsHomeProducts_info(bot) -> Dict[str, Any]: def include_EcoVacsHomeProducts_info(bot) -> dict[str, Any]:
result = copy.deepcopy(bot) result = copy.deepcopy(bot)
for botprod in EcoVacsHomeProducts: for botprod in EcoVacsHomeProducts:

View file

@ -28,7 +28,7 @@ class CommandDto:
self._event = asyncio.Event() self._event = asyncio.Event()
self._response: Union[str, bytes] self._response: Union[str, bytes]
async def wait_for_response(self) -> Union[str, Dict[str, Any]]: async def wait_for_response(self) -> Union[str, dict[str, Any]]:
await self._event.wait() await self._event.wait()
if self._payload_type == "j": if self._payload_type == "j":
return json.loads(self._response) return json.loads(self._response)
@ -87,7 +87,7 @@ class MQTTHelperBot:
async def _wait_for_resp( async def _wait_for_resp(
self, command_dto: CommandDto, request_id: str self, command_dto: CommandDto, request_id: str
) -> Dict[str, Any]: ) -> dict[str, Any]:
try: try:
payload = await asyncio.wait_for( payload = await asyncio.wait_for(
command_dto.wait_for_response(), timeout=self.timeout command_dto.wait_for_response(), timeout=self.timeout
@ -108,8 +108,8 @@ class MQTTHelperBot:
} }
async def send_command( async def send_command(
self, cmdjson: Dict[str, Any], request_id: str self, cmdjson: dict[str, Any], request_id: str
) -> Dict[str, Any]: ) -> dict[str, Any]:
if self.client is None: if self.client is None:
await self.start() await self.start()
assert self.client is not None assert self.client is not None
@ -148,7 +148,7 @@ class MQTTHelperBot:
class MQTTServer: class MQTTServer:
def __init__(self, host: str, port: int, **kwargs: Dict[str, Any]) -> None: def __init__(self, host: str, port: int, **kwargs: dict[str, Any]) -> None:
try: try:
self._host = host self._host = host
self._port = port self._port = port
@ -226,7 +226,7 @@ class BumperMQTTServer_Plugin:
except Exception as e: except Exception as e:
mqttserverlog.exception(f"{e}") mqttserverlog.exception(f"{e}")
async def authenticate(self, session: Session, **kwargs: Dict[str, Any]) -> bool: async def authenticate(self, session: Session, **kwargs: dict[str, Any]) -> bool:
authenticated = False authenticated = False
username = session.username username = session.username
password = session.password password = session.password
@ -314,9 +314,9 @@ class BumperMQTTServer_Plugin:
return authenticated return authenticated
def _read_password_file(self) -> Dict[str, str]: def _read_password_file(self) -> dict[str, str]:
password_file = self.auth_config.get("password-file", None) password_file = self.auth_config.get("password-file", None)
users: Dict[str, str] = {} users: dict[str, str] = {}
if password_file: if password_file:
try: try:
with open(password_file) as f: with open(password_file) as f:
@ -357,7 +357,7 @@ class BumperMQTTServer_Plugin:
bumper.client_set_mqtt(client["resource"], connected) bumper.client_set_mqtt(client["resource"], connected)
async def on_broker_message_received( async def on_broker_message_received(
self, message: IncomingApplicationMessage, **kwargs: Dict[str, Any] self, message: IncomingApplicationMessage, **kwargs: dict[str, Any]
) -> None: ) -> None:
topic = message.topic topic = message.topic
topic_split = str(topic).split("/") topic_split = str(topic).split("/")