From 078cab47bfc5e1c07760a1fc5c44be7f0f82d801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Mon, 2 Sep 2024 15:41:20 +0200 Subject: [PATCH] add FA, ICN, ISC, LOG, PIE and PYI linting --- checks/lib/container-driver/test_driver/__init__.py | 13 ++++++++++--- clanModules/mumble/mumble-populate-channels.py | 1 - pkgs/clan-cli/clan_cli/api/directory.py | 1 - pkgs/clan-cli/clan_cli/qemu/qmp.py | 8 +++++++- pkgs/clan-cli/clan_cli/ssh/__init__.py | 3 +-- pkgs/clan-cli/tests/stdout.py | 9 +++++++-- .../clan_vm_manager/components/vmobj.py | 2 +- .../moonlight_sunshine_accept/sunshine/listen.py | 2 -- pyproject.toml | 6 ++++++ 9 files changed, 32 insertions(+), 13 deletions(-) diff --git a/checks/lib/container-driver/test_driver/__init__.py b/checks/lib/container-driver/test_driver/__init__.py index 997b0e205..179f6ecc7 100644 --- a/checks/lib/container-driver/test_driver/__init__.py +++ b/checks/lib/container-driver/test_driver/__init__.py @@ -3,6 +3,7 @@ import os import re import subprocess import time +import types from collections.abc import Callable from pathlib import Path from tempfile import TemporaryDirectory @@ -95,10 +96,11 @@ class Machine: def get_unit_info(self, unit: str) -> dict[str, str]: proc = self.systemctl(f'--no-pager show "{unit}"') if proc.returncode != 0: - raise Exception( + msg = ( f'retrieving systemctl info for unit "{unit}"' - + f" failed with exit code {proc.returncode}" + f" failed with exit code {proc.returncode}" ) + raise Exception(msg) line_pattern = re.compile(r"^([^=]+)=(.*)$") @@ -311,7 +313,12 @@ class Driver: def __enter__(self) -> "Driver": return self - def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: types.TracebackType | None, + ) -> None: for machine in self.machines: machine.release() diff --git a/clanModules/mumble/mumble-populate-channels.py b/clanModules/mumble/mumble-populate-channels.py index 56ee36668..fe2a99188 100644 --- a/clanModules/mumble/mumble-populate-channels.py +++ b/clanModules/mumble/mumble-populate-channels.py @@ -103,7 +103,6 @@ def initialize_certificates( finally: # Close the connection conn.close() - pass def calculate_digest(cert: str) -> str: diff --git a/pkgs/clan-cli/clan_cli/api/directory.py b/pkgs/clan-cli/clan_cli/api/directory.py index 895749709..09fde1339 100644 --- a/pkgs/clan-cli/clan_cli/api/directory.py +++ b/pkgs/clan-cli/clan_cli/api/directory.py @@ -36,7 +36,6 @@ def open_file(file_request: FileRequest) -> list[str] | None: Abstract api method to open a file dialog window. It must return the name of the selected file or None if no file was selected. """ - pass @dataclass diff --git a/pkgs/clan-cli/clan_cli/qemu/qmp.py b/pkgs/clan-cli/clan_cli/qemu/qmp.py index 2801761f0..69bb86ae4 100644 --- a/pkgs/clan-cli/clan_cli/qemu/qmp.py +++ b/pkgs/clan-cli/clan_cli/qemu/qmp.py @@ -13,6 +13,7 @@ import errno import json import logging import socket +import types from typing import Any @@ -153,7 +154,12 @@ class QEMUMonitorProtocol: # Implement context manager enter function. return self - def __exit__(self, exc_type: Any, exc_value: Any, exc_traceback: Any) -> bool: + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: types.TracebackType | None, + ) -> None: # Implement context manager exit function. self.close() return False diff --git a/pkgs/clan-cli/clan_cli/ssh/__init__.py b/pkgs/clan-cli/clan_cli/ssh/__init__.py index 2f014433d..97c539b8f 100644 --- a/pkgs/clan-cli/clan_cli/ssh/__init__.py +++ b/pkgs/clan-cli/clan_cli/ssh/__init__.py @@ -44,7 +44,7 @@ class CommandFormatter(logging.Formatter): colorcode = 0 if record.levelno == logging.ERROR: colorcode = 31 # red - if record.levelno == logging.WARN: + if record.levelno == logging.WARNING: colorcode = 33 # yellow color, prefix_color, color_reset = "", "", "" @@ -224,7 +224,6 @@ class Host: cmdlog.info( line, extra={"command_prefix": self.command_prefix} ) - pass else: cmdlog.error( line, extra={"command_prefix": self.command_prefix} diff --git a/pkgs/clan-cli/tests/stdout.py b/pkgs/clan-cli/tests/stdout.py index cb9440b4a..eeffbfaa9 100644 --- a/pkgs/clan-cli/tests/stdout.py +++ b/pkgs/clan-cli/tests/stdout.py @@ -1,4 +1,4 @@ -from typing import Any +import types import pytest from pytest import CaptureFixture @@ -15,7 +15,12 @@ class CaptureOutput: self.capsys.readouterr() return self - def __exit__(self, exc_type: Any, exc_value: Any, exc_traceback: Any) -> None: + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_value: BaseException | None, + traceback: types.TracebackType | None, + ) -> None: res = self.capsys.readouterr() self.out = res.out self.err = res.err diff --git a/pkgs/clan-vm-manager/clan_vm_manager/components/vmobj.py b/pkgs/clan-vm-manager/clan_vm_manager/components/vmobj.py index cff066c00..56bd692bf 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/components/vmobj.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/components/vmobj.py @@ -267,7 +267,7 @@ class VMObject(GObject.Object): def start(self) -> None: if self.is_running(): - log.warn("VM is already running. Ignoring start request") + log.warning("VM is already running. Ignoring start request") self.emit("vm_status_changed", self) return log.debug(f"VM state dir {self.log_dir.name}") diff --git a/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/listen.py b/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/listen.py index f6f57a8e6..8bb50b482 100644 --- a/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/listen.py +++ b/pkgs/moonlight-sunshine-accept/moonlight_sunshine_accept/sunshine/listen.py @@ -47,8 +47,6 @@ def listen(port: int, cert: str, uuid: str, state_file: str) -> bool: client_socket.sendall(response.encode("utf-8")) if pair_type == "native": - pass - # url = unquote(data_str.split()[1]) # rec_uuid = parse_qs(urlparse(url).query).get("uuid", [""])[0] # rec_cert = parse_qs(urlparse(url).query).get("cert", [""])[0] diff --git a/pyproject.toml b/pyproject.toml index e9edbad84..ec0393013 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,14 @@ lint.select = [ "E", "EM", "F", + "FA", "I", + "ICN", + "ISC", + "LOG", "N", + "PIE", + "PYI", "RUF", "T10", "TID",