Skip to content

Commit

Permalink
Enable mypy option --strict (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloliverx committed Nov 21, 2022
1 parent 2cb85a2 commit faa166c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
7 changes: 1 addition & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ max-line-length = 120
exclude = httpcore/_sync,tests/_sync

[mypy]
disallow_untyped_defs = True
strict = True
ignore_missing_imports = True
no_implicit_optional = True
show_error_codes = True
warn_unused_ignores = True
disallow_untyped_calls = True
warn_return_any = True
disallow_any_generics = True

[mypy-tests.*]
disallow_untyped_defs = False
Expand Down
6 changes: 3 additions & 3 deletions tests/_async/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import List, Optional

import hpack
import hyperframe.frame
Expand Down Expand Up @@ -124,9 +124,9 @@ async def test_request_to_incorrect_origin():


class NeedsRetryBackend(AsyncMockBackend):
def __init__(self, *args, **kwargs) -> None:
def __init__(self, buffer: List[bytes], http2: bool = False) -> None:
self._retry = 2
super().__init__(*args, **kwargs)
super().__init__(buffer, http2)

async def connect_tcp(
self,
Expand Down
3 changes: 2 additions & 1 deletion tests/_async/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import trio as concurrency

from httpcore import AsyncConnectionPool, ConnectError, PoolTimeout, UnsupportedProtocol
from httpcore.backends.base import AsyncNetworkStream
from httpcore.backends.mock import AsyncMockBackend


Expand Down Expand Up @@ -206,7 +207,7 @@ async def connect_tcp(
port: int,
timeout: Optional[float] = None,
local_address: Optional[str] = None,
):
) -> AsyncNetworkStream:
raise ConnectError("Could not connect")

network_backend = FailedConnectBackend([])
Expand Down
6 changes: 3 additions & 3 deletions tests/_sync/test_connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import List, Optional

import hpack
import hyperframe.frame
Expand Down Expand Up @@ -124,9 +124,9 @@ def test_request_to_incorrect_origin():


class NeedsRetryBackend(MockBackend):
def __init__(self, *args, **kwargs) -> None:
def __init__(self, buffer: List[bytes], http2: bool = False) -> None:
self._retry = 2
super().__init__(*args, **kwargs)
super().__init__(buffer, http2)

def connect_tcp(
self,
Expand Down
3 changes: 2 additions & 1 deletion tests/_sync/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tests import concurrency

from httpcore import ConnectionPool, ConnectError, PoolTimeout, UnsupportedProtocol
from httpcore.backends.base import NetworkStream
from httpcore.backends.mock import MockBackend


Expand Down Expand Up @@ -206,7 +207,7 @@ def connect_tcp(
port: int,
timeout: Optional[float] = None,
local_address: Optional[str] = None,
):
) -> NetworkStream:
raise ConnectError("Could not connect")

network_backend = FailedConnectBackend([])
Expand Down
2 changes: 1 addition & 1 deletion tests/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __exit__(
for thread in self._threads:
thread.join()

def start_soon(self, func: Callable[..., object], *args: Any):
def start_soon(self, func: Callable[..., object], *args: Any) -> None:
thread = threading.Thread(target=func, args=args)
self._threads.append(thread)

Expand Down

0 comments on commit faa166c

Please sign in to comment.