Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable mypy option --strict #616

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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