diff --git a/.coveragerc b/.coveragerc index 61cb5ad822d..0b5d5bf0ad4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,3 +2,7 @@ branch = True source = aiohttp, tests omit = site-packages + +[report] +exclude_also = + if TYPE_CHECKING diff --git a/aiohttp/__init__.py b/aiohttp/__init__.py index 701d913bef4..855dce8ef2c 100644 --- a/aiohttp/__init__.py +++ b/aiohttp/__init__.py @@ -104,7 +104,7 @@ TraceResponseChunkReceivedParams as TraceResponseChunkReceivedParams, ) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: # At runtime these are lazy-loaded at the bottom of the file. from .worker import ( GunicornUVLoopWebWorker as GunicornUVLoopWebWorker, diff --git a/aiohttp/abc.py b/aiohttp/abc.py index ceb4490019a..ee838998997 100644 --- a/aiohttp/abc.py +++ b/aiohttp/abc.py @@ -22,7 +22,7 @@ from .helpers import get_running_loop from .typedefs import LooseCookies -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_app import Application from .web_exceptions import HTTPException from .web_request import BaseRequest, Request @@ -131,7 +131,7 @@ async def close(self) -> None: """Release resolver""" -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: IterableBase = Iterable[Morsel[str]] else: IterableBase = Iterable diff --git a/aiohttp/client_exceptions.py b/aiohttp/client_exceptions.py index 588ffbf6ec6..9aae12a84e8 100644 --- a/aiohttp/client_exceptions.py +++ b/aiohttp/client_exceptions.py @@ -15,7 +15,7 @@ ssl = SSLContext = None # type: ignore[assignment] -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .client_reqrep import ClientResponse, ConnectionKey, Fingerprint, RequestInfo else: RequestInfo = ClientResponse = ConnectionKey = None diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 1d946aea320..4ae0ecbcdfb 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -81,7 +81,7 @@ __all__ = ("ClientRequest", "ClientResponse", "RequestInfo", "Fingerprint") -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .client import ClientSession from .connector import Connection from .tracing import Trace diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 61c26430860..73f58b1a451 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -63,7 +63,7 @@ __all__ = ("BaseConnector", "TCPConnector", "UnixConnector", "NamedPipeConnector") -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .client import ClientTimeout from .client_reqrep import ConnectionKey from .tracing import Trace diff --git a/aiohttp/multipart.py b/aiohttp/multipart.py index 3a8793398d5..602a6b67457 100644 --- a/aiohttp/multipart.py +++ b/aiohttp/multipart.py @@ -59,7 +59,7 @@ ) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .client_reqrep import ClientResponse diff --git a/aiohttp/payload.py b/aiohttp/payload.py index ba856693eed..6593b05c6f7 100644 --- a/aiohttp/payload.py +++ b/aiohttp/payload.py @@ -54,7 +54,7 @@ TOO_LARGE_BYTES_BODY: Final[int] = 2**20 # 1 MB -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from typing import List @@ -401,7 +401,7 @@ def __init__( ) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from typing import AsyncIterable, AsyncIterator _AsyncIterator = AsyncIterator[bytes] diff --git a/aiohttp/test_utils.py b/aiohttp/test_utils.py index 2a026fe704f..b5821a7fb84 100644 --- a/aiohttp/test_utils.py +++ b/aiohttp/test_utils.py @@ -50,7 +50,7 @@ ) from .web_protocol import _RequestHandler -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from ssl import SSLContext else: SSLContext = None diff --git a/aiohttp/tracing.py b/aiohttp/tracing.py index 70e2a62ec1d..62847a0bf7c 100644 --- a/aiohttp/tracing.py +++ b/aiohttp/tracing.py @@ -8,7 +8,7 @@ from .client_reqrep import ClientResponse -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .client import ClientSession _ParamT_contra = TypeVar("_ParamT_contra", contravariant=True) diff --git a/aiohttp/typedefs.py b/aiohttp/typedefs.py index 57d95b384f2..5e963e1a10e 100644 --- a/aiohttp/typedefs.py +++ b/aiohttp/typedefs.py @@ -17,7 +17,7 @@ DEFAULT_JSON_ENCODER = json.dumps DEFAULT_JSON_DECODER = json.loads -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: _CIMultiDict = CIMultiDict[str] _CIMultiDictProxy = CIMultiDictProxy[str] _MultiDict = MultiDict[str] diff --git a/aiohttp/web_app.py b/aiohttp/web_app.py index 6e822b80225..91bf5fdac61 100644 --- a/aiohttp/web_app.py +++ b/aiohttp/web_app.py @@ -60,7 +60,7 @@ __all__ = ("Application", "CleanupError") -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: _AppSignal = Signal[Callable[["Application"], Awaitable[None]]] _RespPrepareSignal = Signal[Callable[[Request, StreamResponse], Awaitable[None]]] _Middlewares = FrozenList[Middleware] @@ -561,7 +561,7 @@ def exceptions(self) -> List[BaseException]: return cast(List[BaseException], self.args[1]) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: _CleanupContextBase = FrozenList[Callable[[Application], AsyncIterator[None]]] else: _CleanupContextBase = FrozenList diff --git a/aiohttp/web_fileresponse.py b/aiohttp/web_fileresponse.py index 0f39c70dcb8..eb7a6a31d39 100644 --- a/aiohttp/web_fileresponse.py +++ b/aiohttp/web_fileresponse.py @@ -31,7 +31,7 @@ __all__ = ("FileResponse",) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_request import BaseRequest diff --git a/aiohttp/web_middlewares.py b/aiohttp/web_middlewares.py index cb24eec9107..5da1533c0df 100644 --- a/aiohttp/web_middlewares.py +++ b/aiohttp/web_middlewares.py @@ -12,7 +12,7 @@ "normalize_path_middleware", ) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_app import Application _Func = TypeVar("_Func") diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py index d0ed0591c17..ec5856a0a22 100644 --- a/aiohttp/web_protocol.py +++ b/aiohttp/web_protocol.py @@ -44,7 +44,7 @@ __all__ = ("RequestHandler", "RequestPayloadError", "PayloadAccessError") -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_server import Server diff --git a/aiohttp/web_request.py b/aiohttp/web_request.py index a7e32ca6c79..61fc831b032 100644 --- a/aiohttp/web_request.py +++ b/aiohttp/web_request.py @@ -66,7 +66,7 @@ __all__ = ("BaseRequest", "FileField", "Request") -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_app import Application from .web_protocol import RequestHandler from .web_urldispatcher import UrlMappingMatchInfo diff --git a/aiohttp/web_response.py b/aiohttp/web_response.py index e089c60ee4c..b6a4ba9b31e 100644 --- a/aiohttp/web_response.py +++ b/aiohttp/web_response.py @@ -44,7 +44,7 @@ __all__ = ("ContentCoding", "StreamResponse", "Response", "json_response") -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_request import BaseRequest BaseClass = MutableMapping[str, Any] diff --git a/aiohttp/web_routedef.py b/aiohttp/web_routedef.py index a1eb0a76549..d79cd32a14a 100644 --- a/aiohttp/web_routedef.py +++ b/aiohttp/web_routedef.py @@ -20,7 +20,7 @@ from .abc import AbstractView from .typedefs import Handler, PathLike -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_request import Request from .web_response import StreamResponse from .web_urldispatcher import AbstractRoute, UrlDispatcher diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py index e398a698818..ea28f15e2b9 100644 --- a/aiohttp/web_urldispatcher.py +++ b/aiohttp/web_urldispatcher.py @@ -69,7 +69,7 @@ ) -if TYPE_CHECKING: # pragma: no cover +if TYPE_CHECKING: from .web_app import Application BaseDict = Dict[str, str]