Skip to content

Commit 4edc9fc

Browse files
HayaoSuzukicsernazs
authored andcommitted
Add type annotations
1 parent 15a8022 commit 4edc9fc

6 files changed

Lines changed: 96 additions & 84 deletions

File tree

pytest_httpserver/blocking_httpserver.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class BlockingRequestHandler(RequestHandlerBase):
2929
This class should only be instantiated inside the implementation of the :py:class:`BlockingHTTPServer`.
3030
"""
3131

32-
def __init__(self):
33-
self.response_queue = Queue()
32+
def __init__(self) -> None:
33+
self.response_queue: Queue[Response] = Queue()
3434

35-
def respond_with_response(self, response: Response):
35+
def respond_with_response(self, response: Response) -> None:
3636
self.response_queue.put_nowait(response)
3737

3838

@@ -59,11 +59,11 @@ class BlockingHTTPServer(HTTPServerBase):
5959

6060
def __init__(
6161
self,
62-
host=DEFAULT_LISTEN_HOST,
63-
port=DEFAULT_LISTEN_PORT,
62+
host: str = DEFAULT_LISTEN_HOST,
63+
port: int = DEFAULT_LISTEN_PORT,
6464
ssl_context: SSLContext | None = None,
6565
timeout: int = 30,
66-
):
66+
) -> None:
6767
super().__init__(host, port, ssl_context)
6868
self.timeout = timeout
6969
self.request_queue: Queue[Request] = Queue()
@@ -76,7 +76,7 @@ def assert_request(
7676
data: str | bytes | None = None,
7777
data_encoding: str = "utf-8",
7878
headers: Mapping[str, str] | None = None,
79-
query_string: None | QueryMatcher | str | bytes | Mapping = None,
79+
query_string: None | QueryMatcher | str | bytes | Mapping[str, str] = None,
8080
header_value_matcher: HeaderValueMatcher | None = None,
8181
json: Any = UNDEFINED,
8282
timeout: int = 30,

pytest_httpserver/hooks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Chain:
2020
similar to reduce.
2121
"""
2222

23-
def __init__(self, *args: Callable[[Request, Response], Response]):
23+
def __init__(self, *args: Callable[[Request, Response], Response]) -> None:
2424
"""
2525
:param *args: callable objects specified in the same order they should
2626
be called.
@@ -43,13 +43,13 @@ class Delay:
4343
Delays returning the response
4444
"""
4545

46-
def __init__(self, seconds: float):
46+
def __init__(self, seconds: float) -> None:
4747
"""
4848
:param seconds: seconds to sleep before returning the response
4949
"""
5050
self._seconds = seconds
5151

52-
def _sleep(self):
52+
def _sleep(self) -> None:
5353
"""
5454
Sleeps for the seconds specified in the constructor
5555
"""
@@ -65,7 +65,7 @@ def __call__(self, _request: Request, response: Response) -> Response:
6565

6666

6767
class Garbage:
68-
def __init__(self, prefix_size: int = 0, suffix_size: int = 0):
68+
def __init__(self, prefix_size: int = 0, suffix_size: int = 0) -> None:
6969
"""
7070
Adds random bytes to the beginning or to the end of the response data.
7171

0 commit comments

Comments
 (0)