diff --git a/mypy.ini b/mypy.ini index 0ed5405..a4c20b8 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,16 +1,26 @@ [mypy] +allow_redefinition = False +allow_untyped_globals = False check_untyped_defs = True -show_error_codes = True -mypy_path = src - -[mypy-mirakuru.*] +disallow_incomplete_defs = True +disallow_subclassing_any = True +disallow_untyped_calls = True +disallow_untyped_decorators = True disallow_untyped_defs = True +follow_imports = silent +ignore_missing_imports = False +implicit_reexport = False +no_implicit_optional = True +pretty = True +show_error_codes = True +strict_equality = True +warn_no_return = True +warn_return_any = True +warn_unreachable = True +warn_unused_ignores = True [mypy-daemon.*] ignore_missing_imports = True [mypy-psutil.*] ignore_missing_imports = True - -[mypy-pytest.*] -ignore_missing_imports = True diff --git a/src/mirakuru/base.py b/src/mirakuru/base.py index 49b40cf..8147ac9 100644 --- a/src/mirakuru/base.py +++ b/src/mirakuru/base.py @@ -101,7 +101,7 @@ def __init__( # pylint:disable=too-many-arguments sleep: float = 0.1, stop_signal: int = signal.SIGTERM, kill_signal: int = SIGKILL, - expected_returncode: int = None, + expected_returncode: Optional[int] = None, envvars: Optional[Dict[str, str]] = None, stdin: Union[None, int, IO[Any]] = subprocess.PIPE, stdout: Union[None, int, IO[Any]] = subprocess.PIPE, @@ -310,8 +310,8 @@ def _kill_all_kids(self, sig: int) -> Set[int]: def stop( self: SimpleExecutorType, - stop_signal: int = None, - expected_returncode: int = None, + stop_signal: Optional[int] = None, + expected_returncode: Optional[int] = None, ) -> SimpleExecutorType: """ Stop process running. @@ -358,7 +358,7 @@ def process_stopped() -> bool: if self.process is None: # the process has already been force killed and cleaned up by the # `wait_for` above. - return self + return self # type: ignore[unreachable] self._kill_all_kids(stop_signal) exit_code = self.process.wait() self._clear_process() diff --git a/src/mirakuru/http.py b/src/mirakuru/http.py index c446bb6..bf44a84 100644 --- a/src/mirakuru/http.py +++ b/src/mirakuru/http.py @@ -39,7 +39,7 @@ def __init__( self, command: Union[str, List[str], Tuple[str, ...]], url: str, - status: str = r"^2\d\d$", + status: Union[str, int] = r"^2\d\d$", method: str = "HEAD", payload: Optional[Dict[str, str]] = None, headers: Optional[Dict[str, str]] = None, diff --git a/tests/__init__.py b/tests/__init__.py index e403991..6105b41 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -18,7 +18,7 @@ HTTP_SERVER_CMD = f"{sys.executable} -m http.server" -def ps_aux(): +def ps_aux() -> str: """ Return output of systems `ps aux -w` call. diff --git a/tests/executors/test_executor.py b/tests/executors/test_executor.py index ddd2722..c049124 100644 --- a/tests/executors/test_executor.py +++ b/tests/executors/test_executor.py @@ -6,6 +6,7 @@ from subprocess import check_output import uuid from unittest import mock +from typing import Union, List import pytest @@ -20,7 +21,7 @@ @pytest.mark.parametrize("command", (SLEEP_300, SLEEP_300.split())) -def test_running_process(command): +def test_running_process(command: Union[str, List[str]]) -> None: """Start process and shuts it down.""" executor = SimpleExecutor(command) executor.start() @@ -34,7 +35,7 @@ def test_running_process(command): @pytest.mark.parametrize("command", (SLEEP_300, SLEEP_300.split())) -def test_command(command): +def test_command(command: Union[str, List[str]]) -> None: """Check that the command and command parts are equivalent.""" executor = SimpleExecutor(command) @@ -42,7 +43,7 @@ def test_command(command): assert executor.command_parts == SLEEP_300.split() -def test_custom_signal_stop(): +def test_custom_signal_stop() -> None: """Start process and shuts it down using signal SIGQUIT.""" executor = SimpleExecutor(SLEEP_300, stop_signal=signal.SIGQUIT) executor.start() @@ -51,7 +52,7 @@ def test_custom_signal_stop(): assert executor.running() is False -def test_stop_custom_signal_stop(): +def test_stop_custom_signal_stop() -> None: """Start process and shuts it down using signal SIGQUIT passed to stop.""" executor = SimpleExecutor(SLEEP_300) executor.start() @@ -60,7 +61,7 @@ def test_stop_custom_signal_stop(): assert executor.running() is False -def test_stop_custom_exit_signal_stop(): +def test_stop_custom_exit_signal_stop() -> None: """Start process and expect it to finish with custom signal.""" executor = SimpleExecutor("false", shell=True) executor.start() @@ -73,7 +74,7 @@ def test_stop_custom_exit_signal_stop(): assert executor.running() is False -def test_stop_custom_exit_signal_context(): +def test_stop_custom_exit_signal_context() -> None: """Start process and expect custom exit signal in context manager.""" with SimpleExecutor( "false", expected_returncode=-3, shell=True @@ -82,7 +83,7 @@ def test_stop_custom_exit_signal_context(): assert executor.running() is False -def test_running_context(): +def test_running_context() -> None: """Start process and shuts it down.""" executor = SimpleExecutor(SLEEP_300) with executor: @@ -91,13 +92,13 @@ def test_running_context(): assert executor.running() is False -def test_executor_in_context_only(): +def test_executor_in_context_only() -> None: """Start process and shuts it down only in context.""" with SimpleExecutor(SLEEP_300) as executor: assert executor.running() is True -def test_context_stopped(): +def test_context_stopped() -> None: """Start for context, and shuts it for nested context.""" executor = SimpleExecutor(SLEEP_300) with executor: @@ -113,7 +114,7 @@ def test_context_stopped(): @pytest.mark.parametrize("command", (ECHO_FOOBAR, shlex.split(ECHO_FOOBAR))) -def test_process_output(command): +def test_process_output(command: Union[str, List[str]]) -> None: """Start process, check output and shut it down.""" executor = SimpleExecutor(command) executor.start() @@ -123,7 +124,7 @@ def test_process_output(command): @pytest.mark.parametrize("command", (ECHO_FOOBAR, shlex.split(ECHO_FOOBAR))) -def test_process_output_shell(command): +def test_process_output_shell(command: Union[str, List[str]]) -> None: """Start process, check output and shut it down with shell set to True.""" executor = SimpleExecutor(command, shell=True) executor.start() @@ -132,7 +133,7 @@ def test_process_output_shell(command): executor.stop() -def test_start_check_executor(): +def test_start_check_executor() -> None: """Validate Executor base class having NotImplemented methods.""" executor = Executor(SLEEP_300) with pytest.raises(NotImplementedError): @@ -141,7 +142,7 @@ def test_start_check_executor(): executor.after_start_check() -def test_stopping_not_yet_running_executor(): +def test_stopping_not_yet_running_executor() -> None: """ Test if SimpleExecutor can be stopped even it was never running. @@ -155,7 +156,7 @@ def test_stopping_not_yet_running_executor(): executor.stop() -def test_forgotten_stop(): +def test_forgotten_stop() -> None: """ Test if SimpleExecutor subprocess is killed after an instance is deleted. @@ -183,7 +184,7 @@ def test_forgotten_stop(): ), "The test process should not be running at this point." -def test_executor_raises_if_process_exits_with_error(): +def test_executor_raises_if_process_exits_with_error() -> None: """ Test process exit detection. @@ -211,10 +212,10 @@ def test_executor_raises_if_process_exits_with_error(): # Pre-start check should have been called - after-start check might or # might not have been called - depending on the timing. - assert failing_executor.pre_start_check.called is True # type: ignore + assert failing_executor.pre_start_check.called is True -def test_executor_ignores_processes_exiting_with_0(): +def test_executor_ignores_processes_exiting_with_0() -> None: """ Test process exit detection. @@ -232,11 +233,11 @@ def test_executor_ignores_processes_exiting_with_0(): executor.start() # Both checks should have been called. - assert executor.pre_start_check.called is True # type: ignore - assert executor.after_start_check.called is True # type: ignore + assert executor.pre_start_check.called is True + assert executor.after_start_check.called is True -def test_executor_methods_returning_self(): +def test_executor_methods_returning_self() -> None: """Test if SimpleExecutor lets to chain start, stop and kill methods.""" executor = SimpleExecutor(SLEEP_300).start().stop().kill().stop() assert not executor.running() @@ -251,7 +252,7 @@ def test_executor_methods_returning_self(): assert SimpleExecutor(SLEEP_300).start().stop().output -def test_mirakuru_cleanup(): +def test_mirakuru_cleanup() -> None: """Test if cleanup_subprocesses is fired correctly on python exit.""" cmd = f""" python -c 'from mirakuru import SimpleExecutor; diff --git a/tests/executors/test_executor_kill.py b/tests/executors/test_executor_kill.py index 8c9377d..ae58616 100644 --- a/tests/executors/test_executor_kill.py +++ b/tests/executors/test_executor_kill.py @@ -3,6 +3,7 @@ import signal import time import sys +from typing import NoReturn, Set import errno @@ -20,7 +21,7 @@ SLEEP_300 = "sleep 300" -def test_custom_signal_kill(): +def test_custom_signal_kill() -> None: """Start process and shuts it down using signal SIGQUIT.""" executor = SimpleExecutor(SLEEP_300, kill_signal=signal.SIGQUIT) executor.start() @@ -29,7 +30,7 @@ def test_custom_signal_kill(): assert executor.running() is False -def test_kill_custom_signal_kill(): +def test_kill_custom_signal_kill() -> None: """Start process and shuts it down using signal SIGQUIT passed to kill.""" executor = SimpleExecutor(SLEEP_300) executor.start() @@ -38,14 +39,14 @@ def test_kill_custom_signal_kill(): assert executor.running() is False -def test_already_closed(): +def test_already_closed() -> None: """Check that the executor cleans after itself after it exited earlier.""" with pytest.raises(ProcessFinishedWithError) as excinfo: with SimpleExecutor("python") as executor: assert executor.running() os.killpg(executor.process.pid, SIGKILL) - def process_stopped(): + def process_stopped() -> bool: """Return True only only when self.process is not running.""" return executor.running() is False @@ -55,7 +56,7 @@ def process_stopped(): assert not executor.process -def test_daemons_killing(): +def test_daemons_killing() -> None: """ Test if all subprocesses of SimpleExecutor can be killed. @@ -75,7 +76,7 @@ def test_daemons_killing(): assert SAMPLE_DAEMON_PATH not in ps_aux() -def test_stopping_brutally(): +def test_stopping_brutally() -> None: """ Test if SimpleExecutor is stopping insubordinate process. @@ -94,7 +95,7 @@ def test_stopping_brutally(): assert stop_at <= time.time(), "Subprocess killed earlier than in 10 secs" -def test_stopping_children_of_stopped_process(): +def test_stopping_children_of_stopped_process() -> None: """ Check that children exiting between listing and killing are ignored. @@ -108,14 +109,14 @@ def test_stopping_children_of_stopped_process(): We ignore and skip OsError indicates there's no such process. """ # pylint: disable=protected-access, missing-docstring - def raise_os_error(*_, **__): + def raise_os_error(*_: int, **__: int) -> NoReturn: os_error = OSError() os_error.errno = errno.ESRCH raise os_error - def processes_with_env_mock(*_, **__): - return [1] + def processes_with_env_mock(*_: str, **__: str) -> Set[int]: + return {1} with patch( "mirakuru.base.processes_with_env", new=processes_with_env_mock diff --git a/tests/executors/test_http_executor.py b/tests/executors/test_http_executor.py index df8dcdc..00c01c3 100644 --- a/tests/executors/test_http_executor.py +++ b/tests/executors/test_http_executor.py @@ -3,7 +3,7 @@ import socket from functools import partial from http.client import HTTPConnection, OK -from typing import Dict, Any +from typing import Dict, Any, Union from unittest.mock import patch import pytest @@ -26,7 +26,7 @@ ) -def connect_to_server(): +def connect_to_server() -> None: """Connect to http server and assert 200 response.""" conn = HTTPConnection(HOST, PORT) conn.request("GET", "/") @@ -34,7 +34,7 @@ def connect_to_server(): conn.close() -def test_executor_starts_and_waits(): +def test_executor_starts_and_waits() -> None: """Test if process awaits for HEAD request to be completed.""" command = f'bash -c "sleep 3 && {HTTP_NORMAL_CMD}"' @@ -51,7 +51,7 @@ def test_executor_starts_and_waits(): assert command in str(executor) -def test_shell_started_server_stops(): +def test_shell_started_server_stops() -> None: """Test if executor terminates properly executor with shell=True.""" executor = HTTPExecutor( HTTP_NORMAL_CMD, f"http://{HOST}:{PORT}/", timeout=20, shell=True @@ -71,7 +71,7 @@ def test_shell_started_server_stops(): @pytest.mark.parametrize("method", ("HEAD", "GET", "POST")) -def test_slow_method_server_starting(method): +def test_slow_method_server_starting(method: str) -> None: """ Test whether or not executor awaits for slow starting servers. @@ -92,7 +92,7 @@ def test_slow_method_server_starting(method): connect_to_server() -def test_slow_post_payload_server_starting(): +def test_slow_post_payload_server_starting() -> None: """ Test whether or not executor awaits for slow starting servers. @@ -115,7 +115,7 @@ def test_slow_post_payload_server_starting(): @pytest.mark.parametrize("method", ("HEAD", "GET", "POST")) -def test_slow_method_server_timed_out(method): +def test_slow_method_server_timed_out(method: str) -> None: """Check if timeout properly expires.""" http_method_slow_cmd = ( @@ -132,7 +132,7 @@ def test_slow_method_server_timed_out(method): assert "timed out after" in str(exc.value) -def test_fail_if_other_running(): +def test_fail_if_other_running() -> None: """Test raising AlreadyRunning exception when port is blocked.""" executor = HTTPExecutor( HTTP_NORMAL_CMD, @@ -157,7 +157,7 @@ def test_fail_if_other_running(): @patch.object(HTTPExecutor, "DEFAULT_PORT", PORT) -def test_default_port(): +def test_default_port() -> None: """ Test default port for the base TCP check. @@ -190,7 +190,9 @@ def test_default_port(): ("(200|404)", False), ), ) -def test_http_status_codes(accepted_status, expected_timeout): +def test_http_status_codes( + accepted_status: Union[None, int, str], expected_timeout: bool +) -> None: """ Test how 'status' argument influences executor start. diff --git a/tests/executors/test_output_executor.py b/tests/executors/test_output_executor.py index 0c22837..6b3c643 100644 --- a/tests/executors/test_output_executor.py +++ b/tests/executors/test_output_executor.py @@ -8,7 +8,7 @@ from mirakuru.exceptions import TimeoutExpired -def test_executor_waits_for_process_output(): +def test_executor_waits_for_process_output() -> None: """Check if executor waits for specified output.""" command = 'bash -c "sleep 2 && echo foo && echo bar && sleep 100"' executor = OutputExecutor(command, "foo", timeout=10).start() @@ -23,7 +23,7 @@ def test_executor_waits_for_process_output(): assert "foo" in str(executor) -def test_executor_waits_for_process_err_output(): +def test_executor_waits_for_process_err_output() -> None: """Check if executor waits for specified error output.""" command = 'bash -c "sleep 2 && >&2 echo foo && >&2 echo bar && sleep 100"' executor = OutputExecutor( @@ -40,7 +40,7 @@ def test_executor_waits_for_process_err_output(): assert "foo" in str(executor) -def test_executor_dont_start(): +def test_executor_dont_start() -> None: """Executor should not start.""" command = 'bash -c "sleep 2 && echo foo && echo bar && sleep 100"' executor = OutputExecutor(command, "foobar", timeout=3) diff --git a/tests/executors/test_pid_executor.py b/tests/executors/test_pid_executor.py index 2db8dd3..69c5240 100644 --- a/tests/executors/test_pid_executor.py +++ b/tests/executors/test_pid_executor.py @@ -1,5 +1,6 @@ """PidExecutor tests.""" import os +from typing import Iterator, Optional import pytest @@ -12,7 +13,7 @@ @pytest.fixture(autouse=True) -def run_around_tests(): +def run_around_tests() -> Iterator[None]: """ Make sure the **FILENAME** file is not present. @@ -32,7 +33,7 @@ def run_around_tests(): pass -def test_start_and_wait(): +def test_start_and_wait() -> None: """Test if the executor will await for the process to create a file.""" process = f'bash -c "sleep 2 && touch {FILENAME} && sleep 10"' with PidExecutor(process, FILENAME, timeout=5) as executor: @@ -44,13 +45,13 @@ def test_start_and_wait(): @pytest.mark.parametrize("pid_file", (None, "")) -def test_empty_filename(pid_file): +def test_empty_filename(pid_file: Optional[str]) -> None: """Check whether an exception is raised if an empty FILENAME is given.""" with pytest.raises(ValueError): - PidExecutor(SLEEP, pid_file) + PidExecutor(SLEEP, pid_file) # type: ignore[arg-type] -def test_if_file_created(): +def test_if_file_created() -> None: """Check whether the process really created the given file.""" assert os.path.isfile(FILENAME) is False executor = PidExecutor(SLEEP, FILENAME) @@ -58,7 +59,7 @@ def test_if_file_created(): assert os.path.isfile(FILENAME) is True -def test_timeout_error(): +def test_timeout_error() -> None: """Check if timeout properly expires.""" executor = PidExecutor(SLEEP, FILENAME, timeout=1) @@ -68,7 +69,7 @@ def test_timeout_error(): assert executor.running() is False -def test_fail_if_other_executor_running(): +def test_fail_if_other_executor_running() -> None: """Test raising AlreadyRunning exception when port is blocked.""" process = f'bash -c "sleep 2 && touch {FILENAME} && sleep 10"' executor = PidExecutor(process, FILENAME) diff --git a/tests/executors/test_tcp_executor.py b/tests/executors/test_tcp_executor.py index ba72f48..3c07c6f 100644 --- a/tests/executors/test_tcp_executor.py +++ b/tests/executors/test_tcp_executor.py @@ -21,7 +21,7 @@ NC_COMMAND = 'bash -c "sleep 2 && nc -lk 3000"' -def test_start_and_wait(caplog: LogCaptureFixture): +def test_start_and_wait(caplog: LogCaptureFixture) -> None: """Test if executor await for process to accept connections.""" caplog.set_level(logging.DEBUG, logger="mirakuru") executor = TCPExecutor(NC_COMMAND, "localhost", port=3000, timeout=5) @@ -30,7 +30,7 @@ def test_start_and_wait(caplog: LogCaptureFixture): executor.stop() -def test_repr_and_str(): +def test_repr_and_str() -> None: """Check the proper str and repr conversion.""" executor = TCPExecutor(NC_COMMAND, "localhost", port=3000, timeout=5) # check proper __str__ and __repr__ rendering: @@ -38,7 +38,7 @@ def test_repr_and_str(): assert NC_COMMAND in str(executor) -def test_it_raises_error_on_timeout(): +def test_it_raises_error_on_timeout() -> None: """Check if TimeoutExpired gets raised correctly.""" command = 'bash -c "sleep 10 && nc -lk 3000"' executor = TCPExecutor(command, host="localhost", port=3000, timeout=2) @@ -49,7 +49,7 @@ def test_it_raises_error_on_timeout(): assert executor.running() is False -def test_fail_if_other_executor_running(): +def test_fail_if_other_executor_running() -> None: """Test raising AlreadyRunning exception.""" executor = TCPExecutor(HTTP_SERVER, host="localhost", port=PORT) executor2 = TCPExecutor(HTTP_SERVER, host="localhost", port=PORT) diff --git a/tests/executors/test_unixsocket_executor.py b/tests/executors/test_unixsocket_executor.py index 768e453..61befd5 100644 --- a/tests/executors/test_unixsocket_executor.py +++ b/tests/executors/test_unixsocket_executor.py @@ -17,7 +17,7 @@ SOCKET_SERVER_CMD = f"{sys.executable} {TEST_SOCKET_SERVER_PATH} {SOCKET_PATH}" -def test_start_and_wait(): +def test_start_and_wait() -> None: """Test if executor await for process to accept connections.""" executor = UnixSocketExecutor( SOCKET_SERVER_CMD + " 2", socket_name=SOCKET_PATH, timeout=5 @@ -26,7 +26,7 @@ def test_start_and_wait(): assert executor.running() is True -def test_start_and_timeout(): +def test_start_and_timeout() -> None: """Test if executor will properly times out.""" executor = UnixSocketExecutor( SOCKET_SERVER_CMD + " 10", socket_name=SOCKET_PATH, timeout=5 diff --git a/tests/retry.py b/tests/retry.py index 57ffe9d..a8f22f9 100644 --- a/tests/retry.py +++ b/tests/retry.py @@ -2,11 +2,19 @@ from datetime import datetime, timedelta from time import sleep +from typing import TypeVar, Callable, Type from mirakuru import ExecutorError -def retry(func, timeout: int = 60, possible_exception=ExecutorError): +T = TypeVar("T") + + +def retry( + func: Callable[[], T], + timeout: int = 60, + possible_exception: Type[Exception] = ExecutorError, +) -> T: """ Attempt to retry the function for timeout time. """ @@ -21,7 +29,6 @@ def retry(func, timeout: int = 60, possible_exception=ExecutorError): except possible_exception as e: if time + timeout_diff < datetime.utcnow(): raise TimeoutError( - "Faile after {i} attempts".format(i=i) + "Failed after {i} attempts".format(i=i) ) from e sleep(1) - pass diff --git a/tests/server_for_tests.py b/tests/server_for_tests.py index deb2f6a..aee8d27 100644 --- a/tests/server_for_tests.py +++ b/tests/server_for_tests.py @@ -33,14 +33,14 @@ class SlowServerHandler(BaseHTTPRequestHandler): timeout = 2 endtime = None - def do_GET(self): # pylint:disable=invalid-name + def do_GET(self) -> None: # pylint:disable=invalid-name """Serve GET request.""" self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(b"Hi. I am very slow.") - def do_HEAD(self): # pylint:disable=invalid-name + def do_HEAD(self) -> None: # pylint:disable=invalid-name """ Serve HEAD request. @@ -51,14 +51,14 @@ def do_HEAD(self): # pylint:disable=invalid-name self.timeout_status() self.end_headers() - def timeout_status(self): + def timeout_status(self) -> None: """Set proper response status based on timeout.""" if self.count_timeout(): self.send_response(200) else: self.send_response(500) - def count_timeout(self): # pylint: disable=no-self-use + def count_timeout(self) -> bool: # pylint: disable=no-self-use """Count down the timeout time.""" if SlowServerHandler.endtime is None: SlowServerHandler.endtime = time.time() + SlowServerHandler.timeout @@ -68,14 +68,14 @@ def count_timeout(self): # pylint: disable=no-self-use class SlowGetServerHandler(SlowServerHandler): """Responds only on GET after a while.""" - def do_GET(self): # pylint:disable=invalid-name + def do_GET(self) -> None: # pylint:disable=invalid-name "Serve GET request." self.timeout_status() self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(b"Hi. I am very slow.") - def do_HEAD(self): # pylint:disable=invalid-name + def do_HEAD(self) -> None: # pylint:disable=invalid-name "Serve HEAD request." self.send_response(500) self.end_headers() @@ -84,13 +84,13 @@ def do_HEAD(self): # pylint:disable=invalid-name class SlowPostServerHandler(SlowServerHandler): """Responds only on POST after a while.""" - def do_POST(self): # pylint:disable=invalid-name + def do_POST(self) -> None: # pylint:disable=invalid-name "Serve POST request." self.timeout_status() self.end_headers() self.wfile.write(b"Hi. I am very slow.") - def do_HEAD(self): # pylint:disable=invalid-name + def do_HEAD(self) -> None: # pylint:disable=invalid-name "Serve HEAD request." self.send_response(500) self.end_headers() @@ -99,7 +99,7 @@ def do_HEAD(self): # pylint:disable=invalid-name class SlowPostKeyServerHandler(SlowServerHandler): """Responds only on POST after a while.""" - def do_POST(self): # pylint:disable=invalid-name + def do_POST(self) -> None: # pylint:disable=invalid-name "Serve POST request." content_len = int(self.headers.get("Content-Length")) post_body = self.rfile.read(content_len) @@ -111,7 +111,7 @@ def do_POST(self): # pylint:disable=invalid-name self.end_headers() self.wfile.write(b"Hi. I am very slow.") - def do_HEAD(self): # pylint:disable=invalid-name + def do_HEAD(self) -> None: # pylint:disable=invalid-name "Serve HEAD request." self.send_response(500) self.end_headers() diff --git a/tests/signals.py b/tests/signals.py index fe275cd..4e4fc19 100644 --- a/tests/signals.py +++ b/tests/signals.py @@ -1,9 +1,10 @@ """Contains `block_signals` function for tests purposes.""" import signal +from typing import Any -def block_signals(): +def block_signals() -> None: """ Catch all of the signals that it is possible. @@ -11,7 +12,7 @@ def block_signals(): only way to kill is to send SIGKILL signal (kill -9). """ - def sighandler(signum, _): + def sighandler(signum: int, _: Any) -> None: """Signal handling function.""" print(f"Tried to kill with signal {signum}.") diff --git a/tests/test_base.py b/tests/test_base.py index baa68fc..a37331b 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -3,7 +3,7 @@ from mirakuru import * -def test_importing_mirakuru(): +def test_importing_mirakuru() -> None: """Test if all most commonly used classes are imported by default.""" assert "Executor" in globals() assert "SimpleExecutor" in globals()