nixos/test-driver: apply ruff fixes & suggestions
This commit is contained in:
parent
93b1fa09d5
commit
a1f01abe53
7 changed files with 29 additions and 29 deletions
|
@ -59,15 +59,15 @@ def main() -> None:
|
||||||
]
|
]
|
||||||
function_definitions.sort(key=lambda x: x.name)
|
function_definitions.sort(key=lambda x: x.name)
|
||||||
|
|
||||||
for f in function_definitions:
|
for function in function_definitions:
|
||||||
docstr = ast.get_docstring(f)
|
docstr = ast.get_docstring(function)
|
||||||
if docstr is not None:
|
if docstr is not None:
|
||||||
args = ", ".join(a.arg for a in f.args.args[1:])
|
args = ", ".join(a.arg for a in function.args.args[1:])
|
||||||
args = f"({args})"
|
args = f"({args})"
|
||||||
|
|
||||||
docstr = "\n".join(f" {l}" for l in docstr.strip().splitlines())
|
docstr = "\n".join(f" {line}" for line in docstr.strip().splitlines())
|
||||||
|
|
||||||
print(f"{f.name}{args}\n\n:{docstr[1:]}\n")
|
print(f"{function.name}{args}\n\n:{docstr[1:]}\n")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
from pathlib import Path
|
|
||||||
import argparse
|
import argparse
|
||||||
import ptpython.repl
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import ptpython.repl
|
||||||
|
|
||||||
from test_driver.logger import rootlog
|
|
||||||
from test_driver.driver import Driver
|
from test_driver.driver import Driver
|
||||||
|
from test_driver.logger import rootlog
|
||||||
|
|
||||||
|
|
||||||
class EnvDefault(argparse.Action):
|
class EnvDefault(argparse.Action):
|
||||||
|
@ -25,9 +26,7 @@ class EnvDefault(argparse.Action):
|
||||||
)
|
)
|
||||||
if required and default:
|
if required and default:
|
||||||
required = False
|
required = False
|
||||||
super(EnvDefault, self).__init__(
|
super().__init__(default=default, required=required, nargs=nargs, **kwargs)
|
||||||
default=default, required=required, nargs=nargs, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
def __call__(self, parser, namespace, values, option_string=None): # type: ignore
|
def __call__(self, parser, namespace, values, option_string=None): # type: ignore
|
||||||
setattr(namespace, self.dest, values)
|
setattr(namespace, self.dest, values)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from contextlib import contextmanager
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any, Dict, Iterator, List, Union, Optional, Callable, ContextManager
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Callable, ContextManager, Dict, Iterator, List, Optional, Union
|
||||||
|
|
||||||
from test_driver.logger import rootlog
|
from test_driver.logger import rootlog
|
||||||
from test_driver.machine import Machine, NixStartScript, retry
|
from test_driver.machine import Machine, NixStartScript, retry
|
||||||
from test_driver.vlan import VLan
|
|
||||||
from test_driver.polling_condition import PollingCondition
|
from test_driver.polling_condition import PollingCondition
|
||||||
|
from test_driver.vlan import VLan
|
||||||
|
|
||||||
|
|
||||||
def get_tmp_dir() -> Path:
|
def get_tmp_dir() -> Path:
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
# mypy: disable-error-code="no-untyped-call"
|
# mypy: disable-error-code="no-untyped-call"
|
||||||
# drop the above line when mypy is upgraded to include
|
# drop the above line when mypy is upgraded to include
|
||||||
# https://github.com/python/typeshed/commit/49b717ca52bf0781a538b04c0d76a5513f7119b8
|
# https://github.com/python/typeshed/commit/49b717ca52bf0781a538b04c0d76a5513f7119b8
|
||||||
from colorama import Style, Fore
|
|
||||||
from contextlib import contextmanager
|
|
||||||
from typing import Any, Dict, Iterator
|
|
||||||
from queue import Queue, Empty
|
|
||||||
from xml.sax.saxutils import XMLGenerator
|
|
||||||
import codecs
|
import codecs
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from queue import Empty, Queue
|
||||||
|
from typing import Any, Dict, Iterator
|
||||||
|
from xml.sax.saxutils import XMLGenerator
|
||||||
|
|
||||||
|
from colorama import Fore, Style
|
||||||
|
|
||||||
|
|
||||||
class Logger:
|
class Logger:
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
from contextlib import _GeneratorContextManager, nullcontext
|
|
||||||
from pathlib import Path
|
|
||||||
from queue import Queue
|
|
||||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
|
|
||||||
import base64
|
import base64
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
@ -16,6 +12,10 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
from contextlib import _GeneratorContextManager, nullcontext
|
||||||
|
from pathlib import Path
|
||||||
|
from queue import Queue
|
||||||
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple
|
||||||
|
|
||||||
from test_driver.logger import rootlog
|
from test_driver.logger import rootlog
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ class Machine:
|
||||||
return (-1, output.decode())
|
return (-1, output.decode())
|
||||||
|
|
||||||
# Get the return code
|
# Get the return code
|
||||||
self.shell.send("echo ${PIPESTATUS[0]}\n".encode())
|
self.shell.send(b"echo ${PIPESTATUS[0]}\n")
|
||||||
rc = int(self._next_newline_closed_block_from_shell().strip())
|
rc = int(self._next_newline_closed_block_from_shell().strip())
|
||||||
|
|
||||||
return (rc, output.decode(errors="replace"))
|
return (rc, output.decode(errors="replace"))
|
||||||
|
@ -1132,7 +1132,7 @@ class Machine:
|
||||||
return
|
return
|
||||||
|
|
||||||
assert self.shell
|
assert self.shell
|
||||||
self.shell.send("poweroff\n".encode())
|
self.shell.send(b"poweroff\n")
|
||||||
self.wait_for_shutdown()
|
self.wait_for_shutdown()
|
||||||
|
|
||||||
def crash(self) -> None:
|
def crash(self) -> None:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import Callable, Optional
|
|
||||||
from math import isfinite
|
|
||||||
import time
|
import time
|
||||||
|
from math import isfinite
|
||||||
|
from typing import Callable, Optional
|
||||||
|
|
||||||
from .logger import rootlog
|
from .logger import rootlog
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from pathlib import Path
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import pty
|
import pty
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from test_driver.logger import rootlog
|
from test_driver.logger import rootlog
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue