Typing: enable disallow_incomplete_defs (#2476)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
The only places mypy reports issues is in the test suite.
authored by Martijn Pieters · committed by GitHub · parent 1ff67ea · Browse files · 8 files·+14 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+14 added−8 removed
- tests:+13 added−8 removed
- other:+1 added−0 removed
Provenance
- Commit
049afe5- Tree
d4bc7d5- Author
Martijn Pieters <mj@zopatista.com>- Committer
GitHub <noreply@github.com>- Parent
1ff67ea
8 files changed+14 added−8 removed
modified:tests/client/test_proxies.py+1 added-1 removed
3 unmodified lines4 import httpx5 from httpx._utils import URLPattern6 7 8-def url_to_origin(url: str):8+def url_to_origin(url: str) -> httpcore.URL:9 """10 Given a URL string, return the origin in the raw tuple format that11 `httpcore` uses for it's representation.12 """274 unmodified linesmodified:tests/conftest.py+2 added-2 removed
288 unmodified lines289 await self.shutdown()290 await self.startup()291 292 293-def serve_in_thread(server: Server):293+def serve_in_thread(server: TestServer) -> typing.Iterator[TestServer]:294 thread = threading.Thread(target=server.run)295 thread.start()296 try:297 while not server.started:4 unmodified lines302 thread.join()303 304 305 @pytest.fixture(scope="session")306-def server():306+def server() -> typing.Iterator[TestServer]:307 config = Config(app=app, lifespan="off", loop="asyncio")308 server = TestServer(config=config)309 yield from serve_in_thread(server)310 13 unmodified linesmodified:tests/test_content.py+1 added-1 removed
65 unmodified lines66 def __init__(self, content):67 self._idx = 068 self._content = content69 70- async def aread(self, chunk_size: int):70+ async def aread(self, chunk_size: int) -> bytes:71 chunk = self._content[self._idx : self._idx + chunk_size]72 self._idx = self._idx + chunk_size73 return chunk74 376 unmodified linesmodified:tests/test_exceptions.py+5 added-1 removed
1+import typing2 from unittest import mock3 4 import httpcore5 import pytest6 7 import httpx8 from httpx._transports.default import HTTPCORE_EXC_MAP9 10+if typing.TYPE_CHECKING: # pragma: no cover11+ from conftest import TestServer12 13+14 def test_httpcore_all_exceptions_mapped() -> None:15 """16 All exception classes exposed by HTTPCore are properly mapped to an HTTPX-specific17 exception class.10 unmodified lines28 if not_mapped: # pragma: no cover29 pytest.fail(f"Unmapped httpcore exceptions: {not_mapped}")30 31 28-def test_httpcore_exception_mapping(server) -> None:32+def test_httpcore_exception_mapping(server: "TestServer") -> None:33 """34 HTTPCore exception mapping works as expected.35 """36 54 unmodified linesmodified:tests/test_multipart.py+1 added-1 removed
150 unmodified lines151 )152 153 154 @pytest.mark.parametrize("content_type", [None, "text/plain"])155-def test_multipart_file_tuple_headers(content_type: typing.Optional[str]):155+def test_multipart_file_tuple_headers(content_type: typing.Optional[str]) -> None:156 file_name = "test.txt"157 expected_content_type = "text/plain"158 headers = {"Expires": "0"}159 293 unmodified linesmodified:tests/test_wsgi.py+1 added-1 removed
142 unmodified lines143 pytest.param("https://www.example.org", "443", id="auto-https"),144 pytest.param("http://www.example.org:8000", "8000", id="explicit-port"),145 ],146 )147-def test_wsgi_server_port(url: str, expected_server_port: int):147+def test_wsgi_server_port(url: str, expected_server_port: int) -> None:148 """149 SERVER_PORT is populated correctly from the requested URL.150 """151 hello_world_app = application_factory([b"Hello, World!"])12 unmodified linesmodified:tests/utils.py+2 added-1 removed
1 import contextlib2 import logging3 import os4+import typing5 6 from httpx import _utils7 8 9 @contextlib.contextmanager9-def override_log_level(log_level: str):10+def override_log_level(log_level: str) -> typing.Iterator[None]:11 os.environ["HTTPX_LOG_LEVEL"] = log_level12 13 # Force a reload on the logging handlers14 _utils._LOGGER_INITIALIZED = False7 unmodified linesmodified:setup.cfg+1 added
13 unmodified lines14 check_untyped_defs = True15 disallow_untyped_decorators = True16 warn_redundant_casts = True17 strict_concatenate = True18+disallow_incomplete_defs = True19 20 [mypy-tests.*]21 disallow_untyped_defs = False22 check_untyped_defs = True17 unmodified lines