mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
lint fixes
This commit is contained in:
parent
bf87f036d3
commit
9158abfab4
@ -26,7 +26,6 @@ import multiprocessing.queues
|
|||||||
import queue
|
import queue
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from typing import Hashable
|
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ def efmt(err: Exception) -> str:
|
|||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
def rget(dct: dict, *keys: Hashable) -> dict:
|
def rget(dct: dict, *keys: str) -> dict:
|
||||||
result = functools.reduce((lambda nxt, key: nxt.get(key, {})), keys, dct)
|
result = functools.reduce((lambda nxt, key: nxt.get(key, {})), keys, dct)
|
||||||
if not isinstance(result, dict):
|
if not isinstance(result, dict):
|
||||||
raise TypeError(f"Not a dict as result: {result!r} from {dct!r} at {list(keys)}")
|
raise TypeError(f"Not a dict as result: {result!r} from {dct!r} at {list(keys)}")
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -138,7 +138,7 @@ def main() -> None:
|
|||||||
classifiers=[
|
classifiers=[
|
||||||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
"Programming Language :: Python :: 3.11",
|
"Programming Language :: Python :: 3.12",
|
||||||
"Topic :: System :: Systems Administration",
|
"Topic :: System :: Systems Administration",
|
||||||
"Operating System :: POSIX :: Linux",
|
"Operating System :: POSIX :: Linux",
|
||||||
"Intended Audience :: System Administrators",
|
"Intended Audience :: System Administrators",
|
||||||
|
|||||||
@ -111,7 +111,7 @@ async def test_fail__region__access_two() -> None:
|
|||||||
|
|
||||||
results = await asyncio.gather(func1(), func2(), return_exceptions=True)
|
results = await asyncio.gather(func1(), func2(), return_exceptions=True)
|
||||||
assert results[0] is None
|
assert results[0] is None
|
||||||
assert type(results[1]) == RegionIsBusyError # pylint: disable=unidiomatic-typecheck
|
assert type(results[1]) is RegionIsBusyError # pylint: disable=unidiomatic-typecheck
|
||||||
|
|
||||||
assert not region.is_busy()
|
assert not region.is_busy()
|
||||||
await region.exit()
|
await region.exit()
|
||||||
|
|||||||
@ -86,7 +86,7 @@ def test_fail__valid_number__min_max(arg: Any) -> None: # pylint: disable=inval
|
|||||||
@pytest.mark.parametrize("arg", [0, 1, 5, "5 "])
|
@pytest.mark.parametrize("arg", [0, 1, 5, "5 "])
|
||||||
def test_ok__valid_int_f0(arg: Any) -> None:
|
def test_ok__valid_int_f0(arg: Any) -> None:
|
||||||
value = valid_int_f0(arg)
|
value = valid_int_f0(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ def test_fail__valid_int_f0(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", [1, 5, "5 "])
|
@pytest.mark.parametrize("arg", [1, 5, "5 "])
|
||||||
def test_ok__valid_int_f1(arg: Any) -> None:
|
def test_ok__valid_int_f1(arg: Any) -> None:
|
||||||
value = valid_int_f1(arg)
|
value = valid_int_f1(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ def test_fail__valid_int_f1(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", [0, 1, 5, "5 ", "5.0 "])
|
@pytest.mark.parametrize("arg", [0, 1, 5, "5 ", "5.0 "])
|
||||||
def test_ok__valid_float_f0(arg: Any) -> None:
|
def test_ok__valid_float_f0(arg: Any) -> None:
|
||||||
value = valid_float_f0(arg)
|
value = valid_float_f0(arg)
|
||||||
assert type(value) == float # pylint: disable=unidiomatic-typecheck
|
assert type(value) is float # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == float(str(arg).strip())
|
assert value == float(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ def test_fail__valid_float_f0(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", [0.1, 1, 5, "5 ", "5.0 "])
|
@pytest.mark.parametrize("arg", [0.1, 1, 5, "5 ", "5.0 "])
|
||||||
def test_ok__valid_float_f01(arg: Any) -> None:
|
def test_ok__valid_float_f01(arg: Any) -> None:
|
||||||
value = valid_float_f01(arg)
|
value = valid_float_f01(arg)
|
||||||
assert type(value) == float # pylint: disable=unidiomatic-typecheck
|
assert type(value) is float # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == float(str(arg).strip())
|
assert value == float(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ from kvmd.validators.hw import valid_otg_ethernet
|
|||||||
@pytest.mark.parametrize("arg", ["1200 ", 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200])
|
@pytest.mark.parametrize("arg", ["1200 ", 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200])
|
||||||
def test_ok__valid_tty_speed(arg: Any) -> None:
|
def test_ok__valid_tty_speed(arg: Any) -> None:
|
||||||
value = valid_tty_speed(arg)
|
value = valid_tty_speed(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ def test_fail__valid_tty_speed(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13])
|
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13])
|
||||||
def test_ok__valid_gpio_pin(arg: Any) -> None:
|
def test_ok__valid_gpio_pin(arg: Any) -> None:
|
||||||
value = valid_gpio_pin(arg)
|
value = valid_gpio_pin(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ def test_fail__valid_gpio_pin(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["0 ", -1, 0, 1, 13])
|
@pytest.mark.parametrize("arg", ["0 ", -1, 0, 1, 13])
|
||||||
def test_ok__valid_gpio_pin_optional(arg: Any) -> None:
|
def test_ok__valid_gpio_pin_optional(arg: Any) -> None:
|
||||||
value = valid_gpio_pin_optional(arg)
|
value = valid_gpio_pin_optional(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ def test_fail__valid_otg_gadget(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13, 65535])
|
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13, 65535])
|
||||||
def test_ok__valid_otg_id(arg: Any) -> None:
|
def test_ok__valid_otg_id(arg: Any) -> None:
|
||||||
value = valid_otg_id(arg)
|
value = valid_otg_id(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,7 @@ def test_fail__valid_msd_image_name(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", [" foo ", "bar", "foo, ,bar,", " ", " , ", ""])
|
@pytest.mark.parametrize("arg", [" foo ", "bar", "foo, ,bar,", " ", " , ", ""])
|
||||||
def test_ok__valid_info_fields(arg: Any) -> None:
|
def test_ok__valid_info_fields(arg: Any) -> None:
|
||||||
value = valid_info_fields(arg, set(["foo", "bar"]))
|
value = valid_info_fields(arg, set(["foo", "bar"]))
|
||||||
assert type(value) == set # pylint: disable=unidiomatic-typecheck
|
assert type(value) is set # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == set(filter(None, map(str.strip, str(arg).split(","))))
|
assert value == set(filter(None, map(str.strip, str(arg).split(","))))
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ def test_fail__valid_info_fields(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13])
|
@pytest.mark.parametrize("arg", ["0 ", 0, 1, 13])
|
||||||
def test_ok__valid_log_seek(arg: Any) -> None:
|
def test_ok__valid_log_seek(arg: Any) -> None:
|
||||||
value = valid_log_seek(arg)
|
value = valid_log_seek(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ def test_fail__valid_log_seek(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["1 ", 20, 100])
|
@pytest.mark.parametrize("arg", ["1 ", 20, 100])
|
||||||
def test_ok__valid_stream_quality(arg: Any) -> None:
|
def test_ok__valid_stream_quality(arg: Any) -> None:
|
||||||
value = valid_stream_quality(arg)
|
value = valid_stream_quality(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ def test_fail__valid_stream_quality(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["1 ", 120])
|
@pytest.mark.parametrize("arg", ["1 ", 120])
|
||||||
def test_ok__valid_stream_fps(arg: Any) -> None:
|
def test_ok__valid_stream_fps(arg: Any) -> None:
|
||||||
value = valid_stream_fps(arg)
|
value = valid_stream_fps(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ def test_fail__valid_stream_fps(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["1280x720 ", "1x1"])
|
@pytest.mark.parametrize("arg", ["1280x720 ", "1x1"])
|
||||||
def test_ok__valid_stream_resolution(arg: Any) -> None:
|
def test_ok__valid_stream_resolution(arg: Any) -> None:
|
||||||
value = valid_stream_resolution(arg)
|
value = valid_stream_resolution(arg)
|
||||||
assert type(value) == str # pylint: disable=unidiomatic-typecheck
|
assert type(value) is str # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == str(arg).strip()
|
assert value == str(arg).strip()
|
||||||
|
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ def test_fail__valid_stream_resolution(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["25", " 20000 ", 5000])
|
@pytest.mark.parametrize("arg", ["25", " 20000 ", 5000])
|
||||||
def test_ok__valid_stream_h264_bitrate(arg: Any) -> None:
|
def test_ok__valid_stream_h264_bitrate(arg: Any) -> None:
|
||||||
value = valid_stream_h264_bitrate(arg)
|
value = valid_stream_h264_bitrate(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ def test_fail__valid_stream_h264_bitrate(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["1 ", 0, 60])
|
@pytest.mark.parametrize("arg", ["1 ", 0, 60])
|
||||||
def test_ok__valid_stream_h264_gop(arg: Any) -> None:
|
def test_ok__valid_stream_h264_gop(arg: Any) -> None:
|
||||||
value = valid_stream_h264_gop(arg)
|
value = valid_stream_h264_gop(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,7 @@ def test_fail__valid_rfc_host(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", ["0 ", 0, "22", 443, 65535])
|
@pytest.mark.parametrize("arg", ["0 ", 0, "22", 443, 65535])
|
||||||
def test_ok__valid_port(arg: Any) -> None:
|
def test_ok__valid_port(arg: Any) -> None:
|
||||||
value = valid_port(arg)
|
value = valid_port(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(arg).strip())
|
assert value == int(str(arg).strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,7 @@ def test_fail__valid_printable_filename(arg: Any) -> None:
|
|||||||
@pytest.mark.parametrize("arg", [0, 5, "1000"])
|
@pytest.mark.parametrize("arg", [0, 5, "1000"])
|
||||||
def test_ok__valid_unix_mode(arg: Any) -> None:
|
def test_ok__valid_unix_mode(arg: Any) -> None:
|
||||||
value = valid_unix_mode(arg)
|
value = valid_unix_mode(arg)
|
||||||
assert type(value) == int # pylint: disable=unidiomatic-typecheck
|
assert type(value) is int # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == int(str(value).strip())
|
assert value == int(str(value).strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ def test_fail__valid_ugpio_item(validator: Callable[[Any], str], arg: Any) -> No
|
|||||||
@pytest.mark.parametrize("arg", ["foo", " bar", " baz "])
|
@pytest.mark.parametrize("arg", ["foo", " bar", " baz "])
|
||||||
def test_ok__valid_ugpio_driver_variants(arg: Any) -> None:
|
def test_ok__valid_ugpio_driver_variants(arg: Any) -> None:
|
||||||
value = valid_ugpio_driver(arg, set(["foo", "bar", "baz"]))
|
value = valid_ugpio_driver(arg, set(["foo", "bar", "baz"]))
|
||||||
assert type(value) == str # pylint: disable=unidiomatic-typecheck
|
assert type(value) is str # pylint: disable=unidiomatic-typecheck
|
||||||
assert value == str(arg).strip()
|
assert value == str(arg).strip()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint, shellcheck
|
|||||||
skipsdist = true
|
skipsdist = true
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
basepython = python3.11
|
basepython = python3.12
|
||||||
sitepackages = true
|
sitepackages = true
|
||||||
changedir = /src
|
changedir = /src
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ changedir = /src
|
|||||||
allowlist_externals = bash
|
allowlist_externals = bash
|
||||||
commands = bash -c 'flake8 --config=testenv/linters/flake8.ini kvmd testenv/tests *.py'
|
commands = bash -c 'flake8 --config=testenv/linters/flake8.ini kvmd testenv/tests *.py'
|
||||||
deps =
|
deps =
|
||||||
flake8==5.0.4
|
flake8
|
||||||
flake8-quotes
|
flake8-quotes
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user