Merge pull request 'add FA, ICN, ISC, LOG, PIE and PYI linting' (#2017) from type-checking into main
This commit is contained in:
@@ -3,6 +3,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
import types
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
@@ -95,10 +96,11 @@ class Machine:
|
|||||||
def get_unit_info(self, unit: str) -> dict[str, str]:
|
def get_unit_info(self, unit: str) -> dict[str, str]:
|
||||||
proc = self.systemctl(f'--no-pager show "{unit}"')
|
proc = self.systemctl(f'--no-pager show "{unit}"')
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise Exception(
|
msg = (
|
||||||
f'retrieving systemctl info for unit "{unit}"'
|
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"^([^=]+)=(.*)$")
|
line_pattern = re.compile(r"^([^=]+)=(.*)$")
|
||||||
|
|
||||||
@@ -311,7 +313,12 @@ class Driver:
|
|||||||
def __enter__(self) -> "Driver":
|
def __enter__(self) -> "Driver":
|
||||||
return self
|
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:
|
for machine in self.machines:
|
||||||
machine.release()
|
machine.release()
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ def initialize_certificates(
|
|||||||
finally:
|
finally:
|
||||||
# Close the connection
|
# Close the connection
|
||||||
conn.close()
|
conn.close()
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_digest(cert: str) -> str:
|
def calculate_digest(cert: str) -> str:
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ def open_file(file_request: FileRequest) -> list[str] | None:
|
|||||||
Abstract api method to open a file dialog window.
|
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.
|
It must return the name of the selected file or None if no file was selected.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import errno
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
import types
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
@@ -153,7 +154,12 @@ class QEMUMonitorProtocol:
|
|||||||
# Implement context manager enter function.
|
# Implement context manager enter function.
|
||||||
return self
|
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.
|
# Implement context manager exit function.
|
||||||
self.close()
|
self.close()
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class CommandFormatter(logging.Formatter):
|
|||||||
colorcode = 0
|
colorcode = 0
|
||||||
if record.levelno == logging.ERROR:
|
if record.levelno == logging.ERROR:
|
||||||
colorcode = 31 # red
|
colorcode = 31 # red
|
||||||
if record.levelno == logging.WARN:
|
if record.levelno == logging.WARNING:
|
||||||
colorcode = 33 # yellow
|
colorcode = 33 # yellow
|
||||||
|
|
||||||
color, prefix_color, color_reset = "", "", ""
|
color, prefix_color, color_reset = "", "", ""
|
||||||
@@ -224,7 +224,6 @@ class Host:
|
|||||||
cmdlog.info(
|
cmdlog.info(
|
||||||
line, extra={"command_prefix": self.command_prefix}
|
line, extra={"command_prefix": self.command_prefix}
|
||||||
)
|
)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
cmdlog.error(
|
cmdlog.error(
|
||||||
line, extra={"command_prefix": self.command_prefix}
|
line, extra={"command_prefix": self.command_prefix}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any
|
import types
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest import CaptureFixture
|
from pytest import CaptureFixture
|
||||||
@@ -15,7 +15,12 @@ class CaptureOutput:
|
|||||||
self.capsys.readouterr()
|
self.capsys.readouterr()
|
||||||
return self
|
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()
|
res = self.capsys.readouterr()
|
||||||
self.out = res.out
|
self.out = res.out
|
||||||
self.err = res.err
|
self.err = res.err
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ class VMObject(GObject.Object):
|
|||||||
|
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
if self.is_running():
|
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)
|
self.emit("vm_status_changed", self)
|
||||||
return
|
return
|
||||||
log.debug(f"VM state dir {self.log_dir.name}")
|
log.debug(f"VM state dir {self.log_dir.name}")
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ def listen(port: int, cert: str, uuid: str, state_file: str) -> bool:
|
|||||||
client_socket.sendall(response.encode("utf-8"))
|
client_socket.sendall(response.encode("utf-8"))
|
||||||
|
|
||||||
if pair_type == "native":
|
if pair_type == "native":
|
||||||
pass
|
|
||||||
|
|
||||||
# url = unquote(data_str.split()[1])
|
# url = unquote(data_str.split()[1])
|
||||||
# rec_uuid = parse_qs(urlparse(url).query).get("uuid", [""])[0]
|
# rec_uuid = parse_qs(urlparse(url).query).get("uuid", [""])[0]
|
||||||
# rec_cert = parse_qs(urlparse(url).query).get("cert", [""])[0]
|
# rec_cert = parse_qs(urlparse(url).query).get("cert", [""])[0]
|
||||||
|
|||||||
@@ -20,8 +20,14 @@ lint.select = [
|
|||||||
"E",
|
"E",
|
||||||
"EM",
|
"EM",
|
||||||
"F",
|
"F",
|
||||||
|
"FA",
|
||||||
"I",
|
"I",
|
||||||
|
"ICN",
|
||||||
|
"ISC",
|
||||||
|
"LOG",
|
||||||
"N",
|
"N",
|
||||||
|
"PIE",
|
||||||
|
"PYI",
|
||||||
"RUF",
|
"RUF",
|
||||||
"T10",
|
"T10",
|
||||||
"TID",
|
"TID",
|
||||||
|
|||||||
Reference in New Issue
Block a user