Skip to content
Myr

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

8 files+14 added−8 removed

modified:tests/client/test_proxies.py+1 added-1 removed
3 unmodified lines
4import httpx5from httpx._utils import URLPattern678def url_to_origin(url: str):8def 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 lines
modified:tests/conftest.py+2 added-2 removed
288 unmodified lines
289 await self.shutdown()290 await self.startup()291292293def serve_in_thread(server: Server):293def 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 lines
302 thread.join()303304305@pytest.fixture(scope="session")306def server():306def 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 lines
modified:tests/test_content.py+1 added-1 removed
65 unmodified lines
66 def __init__(self, content):67 self._idx = 068 self._content = content6970 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 lines
modified:tests/test_exceptions.py+5 added-1 removed
1import typing2from unittest import mock34import httpcore5import pytest67import httpx8from httpx._transports.default import HTTPCORE_EXC_MAP910if typing.TYPE_CHECKING: # pragma: no cover11 from conftest import TestServer121314def 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 lines
28 if not_mapped: # pragma: no cover29 pytest.fail(f"Unmapped httpcore exceptions: {not_mapped}")303128def test_httpcore_exception_mapping(server) -> None:32def test_httpcore_exception_mapping(server: "TestServer") -> None:33 """34 HTTPCore exception mapping works as expected.35 """36
54 unmodified lines
modified:tests/test_multipart.py+1 added-1 removed
150 unmodified lines
151 )152153154@pytest.mark.parametrize("content_type", [None, "text/plain"])155def test_multipart_file_tuple_headers(content_type: typing.Optional[str]):155def 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 lines
modified:tests/test_wsgi.py+1 added-1 removed
142 unmodified lines
143 pytest.param("https://www.example.org", "443", id="auto-https"),144 pytest.param("http://www.example.org:8000", "8000", id="explicit-port"),145 ],146)147def test_wsgi_server_port(url: str, expected_server_port: int):147def 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 lines
modified:tests/utils.py+2 added-1 removed
1import contextlib2import logging3import os4import typing56from httpx import _utils789@contextlib.contextmanager9def override_log_level(log_level: str):10def override_log_level(log_level: str) -> typing.Iterator[None]:11 os.environ["HTTPX_LOG_LEVEL"] = log_level1213 # Force a reload on the logging handlers14 _utils._LOGGER_INITIALIZED = False
7 unmodified lines
modified:setup.cfg+1 added
13 unmodified lines
14check_untyped_defs = True15disallow_untyped_decorators = True16warn_redundant_casts = True17strict_concatenate = True18disallow_incomplete_defs = True1920[mypy-tests.*]21disallow_untyped_defs = False22check_untyped_defs = True
17 unmodified lines