Skip to content

Commit

Permalink
Use .coveragerc for TYPE_CHECKING conditions (#7930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Dec 2, 2023
1 parent 669109f commit 895afa8
Show file tree
Hide file tree
Showing 19 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
branch = True
source = aiohttp, tests
omit = site-packages

[report]
exclude_also =
if TYPE_CHECKING
2 changes: 1 addition & 1 deletion aiohttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
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, GunicornWebWorker

Expand Down
4 changes: 2 additions & 2 deletions aiohttp/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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
Expand Down Expand Up @@ -129,7 +129,7 @@ async def close(self) -> None:
"""Release resolver"""


if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
IterableBase = Iterable[Morsel[str]]
else:
IterableBase = Iterable
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,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
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
)


if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from .client_reqrep import ClientResponse


Expand Down
4 changes: 2 additions & 2 deletions aiohttp/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -397,7 +397,7 @@ def __init__(
)


if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from typing import AsyncIterable, AsyncIterator

_AsyncIterator = AsyncIterator[bytes]
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
)
from .web_protocol import _RequestHandler

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from ssl import SSLContext
else:
SSLContext = None
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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]
Expand Down Expand Up @@ -412,7 +412,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
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

__all__ = ("FileResponse",)

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from .web_request import BaseRequest


Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"normalize_path_middleware",
)

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from .web_app import Application

_Func = TypeVar("_Func")
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

__all__ = ("RequestHandler", "RequestPayloadError", "PayloadAccessError")

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from .web_server import Server


Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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]
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_routedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
)


if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from .web_app import Application

BaseDict = Dict[str, str]
Expand Down

0 comments on commit 895afa8

Please sign in to comment.