Skip to content

Bump mypy from 1.15.0 to 1.16.0 #11093

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

Merged
merged 18 commits into from
Jun 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aiohttp/abc.py
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ def http_exception(self) -> Optional[HTTPException]:
"""HTTPException instance raised on router's resolving, or None"""

@abstractmethod # pragma: no branch
def get_info(self) -> Dict[str, Any]: # type: ignore[misc]
def get_info(self) -> Dict[str, Any]:
"""Return a dict with additional info useful for introspection"""

@property # pragma: no branch
4 changes: 2 additions & 2 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
@@ -1290,7 +1290,7 @@ def skip_auto_headers(self) -> FrozenSet[istr]:
return self._skip_auto_headers

@property
def auth(self) -> Optional[BasicAuth]: # type: ignore[misc]
def auth(self) -> Optional[BasicAuth]:
"""An object that represents HTTP Basic Authorization"""
return self._default_auth

@@ -1327,7 +1327,7 @@ def trust_env(self) -> bool:
return self._trust_env

@property
def trace_configs(self) -> List[TraceConfig[Any]]: # type: ignore[misc]
def trace_configs(self) -> List[TraceConfig[Any]]:
"""A list of TraceConfig instances used for client tracing"""
return self._trace_configs

2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
@@ -847,7 +847,7 @@ def ssl(self) -> Union["SSLContext", bool, Fingerprint]:
return self._ssl

@property
def connection_key(self) -> ConnectionKey: # type: ignore[misc]
def connection_key(self) -> ConnectionKey:
if proxy_headers := self.proxy_headers:
h: Optional[int] = hash(tuple(proxy_headers.items()))
else:
2 changes: 1 addition & 1 deletion aiohttp/formdata.py
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ def add_fields(self, *fields: Any) -> None:

elif isinstance(rec, (list, tuple)) and len(rec) == 2:
k, fp = rec
self.add_field(k, fp) # type: ignore[arg-type]
self.add_field(k, fp)

else:
raise TypeError(
10 changes: 5 additions & 5 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ def __new__(
return super().__new__(cls, login, password, encoding)

@classmethod
def decode(cls, auth_header: str, encoding: str = "latin1") -> "BasicAuth": # type: ignore[misc]
def decode(cls, auth_header: str, encoding: str = "latin1") -> "BasicAuth":
"""Create a BasicAuth object from an Authorization HTTP header."""
try:
auth_type, encoded_credentials = auth_header.split(" ", 1)
@@ -174,7 +174,7 @@ def decode(cls, auth_header: str, encoding: str = "latin1") -> "BasicAuth": # t
return cls(username, password, encoding=encoding)

@classmethod
def from_url(cls, url: URL, *, encoding: str = "latin1") -> Optional["BasicAuth"]: # type: ignore[misc]
def from_url(cls, url: URL, *, encoding: str = "latin1") -> Optional["BasicAuth"]:
"""Create BasicAuth from url."""
if not isinstance(url, URL):
raise TypeError("url should be yarl.URL instance")
@@ -245,7 +245,7 @@ def netrc_from_env() -> Optional[netrc.netrc]:


@frozen_dataclass_decorator
class ProxyInfo: # type: ignore[misc]
class ProxyInfo:
proxy: URL
proxy_auth: Optional[BasicAuth]

@@ -884,7 +884,7 @@ def __init_subclass__(cls) -> None:
def __getitem__(self, key: AppKey[_T]) -> _T: ...

@overload
def __getitem__(self, key: str) -> Any: ... # type: ignore[misc]
def __getitem__(self, key: str) -> Any: ...

def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
for mapping in self._maps:
@@ -901,7 +901,7 @@ def get(self, key: AppKey[_T], default: _S) -> Union[_T, _S]: ...
def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]: ...

@overload
def get(self, key: str, default: Any = ...) -> Any: ... # type: ignore[misc]
def get(self, key: str, default: Any = ...) -> Any: ...

def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
try:
4 changes: 2 additions & 2 deletions aiohttp/http_writer.py
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ def _write(
transport = self._protocol.transport
if transport is None or transport.is_closing():
raise ClientConnectionResetError("Cannot write to closing transport")
transport.write(chunk) # type: ignore[arg-type]
transport.write(chunk)

def _writelines(
self,
@@ -119,7 +119,7 @@ def _writelines(
if SKIP_WRITELINES or size < MIN_PAYLOAD_FOR_WRITELINES:
transport.write(b"".join(chunks))
else:
transport.writelines(chunks) # type: ignore[arg-type]
transport.writelines(chunks)

def _write_chunked_payload(
self, chunk: Union[bytes, bytearray, "memoryview[int]", "memoryview[bytes]"]
8 changes: 4 additions & 4 deletions aiohttp/pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -42,15 +42,15 @@
class AiohttpClient(Protocol):
# TODO(PY311): Use Unpack to specify ClientSession kwargs.
@overload
async def __call__( # type: ignore[misc]
async def __call__(
self,
__param: Application,
*,
server_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> TestClient[Request, Application]: ...
@overload
async def __call__( # type: ignore[misc]
async def __call__(
self,
__param: BaseTestServer[_Request],
*,
@@ -400,14 +400,14 @@ def aiohttp_client( # type: ignore[misc]
clients = []

@overload
async def go( # type: ignore[misc]
async def go(
__param: Application,
*,
server_kwargs: Optional[Dict[str, Any]] = None,
**kwargs: Any,
) -> TestClient[Request, Application]: ...
@overload
async def go( # type: ignore[misc]
async def go(
__param: BaseTestServer[_Request],
*,
server_kwargs: Optional[Dict[str, Any]] = None,
6 changes: 3 additions & 3 deletions aiohttp/test_utils.py
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ async def start_server(self, **kwargs: Any) -> None:
self._root = URL(f"{self.scheme}://{absolute_host}:{self.port}")

@abstractmethod
async def _make_runner(self, **kwargs: Any) -> BaseRunner[_Request]: # type: ignore[misc]
async def _make_runner(self, **kwargs: Any) -> BaseRunner[_Request]:
"""Return a new runner for the server."""
# TODO(PY311): Use Unpack to specify Server kwargs.

@@ -265,15 +265,15 @@ class TestClient(Generic[_Request, _ApplicationNone]):
__test__ = False

@overload
def __init__( # type: ignore[misc]
def __init__(
self: "TestClient[Request, Application]",
server: TestServer,
*,
cookie_jar: Optional[AbstractCookieJar] = None,
**kwargs: Any,
) -> None: ...
@overload
def __init__( # type: ignore[misc]
def __init__(
self: "TestClient[_Request, None]",
server: BaseTestServer[_Request],
*,
6 changes: 3 additions & 3 deletions aiohttp/web_app.py
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ def __eq__(self, other: object) -> bool:
def __getitem__(self, key: AppKey[_T]) -> _T: ...

@overload
def __getitem__(self, key: str) -> Any: ... # type: ignore[misc]
def __getitem__(self, key: str) -> Any: ...

def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
return self._state[key]
@@ -179,7 +179,7 @@ def _check_frozen(self) -> None:
def __setitem__(self, key: AppKey[_T], value: _T) -> None: ...

@overload
def __setitem__(self, key: str, value: Any) -> None: ... # type: ignore[misc]
def __setitem__(self, key: str, value: Any) -> None: ...

def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:
self._check_frozen()
@@ -213,7 +213,7 @@ def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]: ...
def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]: ...

@overload
def get(self, key: str, default: Any = ...) -> Any: ... # type: ignore[misc]
def get(self, key: str, default: Any = ...) -> Any: ...

def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
return self._state.get(key, default)
8 changes: 4 additions & 4 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
@@ -160,8 +160,8 @@ async def _not_modified(
) -> Optional[AbstractStreamWriter]:
self.set_status(HTTPNotModified.status_code)
self._length_check = False
self.etag = etag_value # type: ignore[assignment]
self.last_modified = last_modified # type: ignore[assignment]
self.etag = etag_value
self.last_modified = last_modified
# Delete any Content-Length headers provided by user. HTTP 304
# should always have empty response body
return await super().prepare(request)
@@ -391,8 +391,8 @@ async def _prepare_open_file(
# compress.
self._compression = False

self.etag = f"{st.st_mtime_ns:x}-{st.st_size:x}" # type: ignore[assignment]
self.last_modified = file_mtime # type: ignore[assignment]
self.etag = f"{st.st_mtime_ns:x}-{st.st_size:x}"
self.last_modified = file_mtime
self.content_length = count

self._headers[hdrs.ACCEPT_RANGES] = "bytes"
4 changes: 2 additions & 2 deletions aiohttp/web_routedef.py
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ def register(self, router: UrlDispatcher) -> List[AbstractRoute]:


@dataclasses.dataclass(frozen=True, repr=False)
class RouteDef(AbstractRouteDef): # type: ignore[misc]
class RouteDef(AbstractRouteDef):
method: str
path: str
handler: _HandlerType
@@ -79,7 +79,7 @@ def register(self, router: UrlDispatcher) -> List[AbstractRoute]:


@dataclasses.dataclass(frozen=True, repr=False)
class StaticDef(AbstractRouteDef): # type: ignore[misc]
class StaticDef(AbstractRouteDef):
prefix: str
path: PathLike
kwargs: Dict[str, Any]
2 changes: 1 addition & 1 deletion aiohttp/web_runner.py
Original file line number Diff line number Diff line change
@@ -254,7 +254,7 @@ def server(self) -> Optional[Server[_Request]]:
return self._server

@property
def addresses(self) -> List[Any]: # type: ignore[misc]
def addresses(self) -> List[Any]:
ret: List[Any] = []
for site in self._sites:
server = site._server
4 changes: 2 additions & 2 deletions aiohttp/web_server.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ class Server(Generic[_Request]):
request_factory: _RequestFactory[_Request]

@overload
def __init__( # type: ignore[misc]
def __init__(
self: "Server[BaseRequest]",
handler: Callable[[_Request], Awaitable[StreamResponse]],
*,
@@ -49,7 +49,7 @@ def __init__( # type: ignore[misc]
**kwargs: Any, # TODO(PY311): Use Unpack to define kwargs from RequestHandler
) -> None: ...
@overload
def __init__( # type: ignore[misc]
def __init__(
self,
handler: Callable[[_Request], Awaitable[StreamResponse]],
*,
2 changes: 1 addition & 1 deletion aiohttp/worker.py
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ def handle_abort(self, sig: int, frame: Optional[FrameType]) -> None:
sys.exit(1)

@staticmethod
def _create_ssl_context(cfg: Any) -> "SSLContext": # type: ignore[misc]
def _create_ssl_context(cfg: Any) -> "SSLContext":
"""Creates SSLContext instance for usage in asyncio.create_server.

See ssl.SSLSocket.__init__ for more details.
4 changes: 3 additions & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ multidict==6.4.4
# -r requirements/multidict.in
# -r requirements/runtime-deps.in
# yarl
mypy==1.15.0 ; implementation_name == "cpython"
mypy==1.16.1 ; implementation_name == "cpython"
# via
# -r requirements/lint.in
# -r requirements/test.in
@@ -133,6 +133,8 @@ packaging==25.0
# pytest
# sphinx
# wheel
pathspec==0.12.1
# via mypy
pip-tools==7.4.1
# via -r requirements/dev.in
pkgconfig==1.5.5
4 changes: 3 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ multidict==6.4.4
# via
# -r requirements/runtime-deps.in
# yarl
mypy==1.15.0 ; implementation_name == "cpython"
mypy==1.16.1 ; implementation_name == "cpython"
# via
# -r requirements/lint.in
# -r requirements/test.in
@@ -130,6 +130,8 @@ packaging==25.0
# pytest
# sphinx
# wheel
pathspec==0.12.1
# via mypy
pip-tools==7.4.1
# via -r requirements/dev.in
pkgconfig==1.5.5
4 changes: 3 additions & 1 deletion requirements/lint.txt
Original file line number Diff line number Diff line change
@@ -45,14 +45,16 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.15.0 ; implementation_name == "cpython"
mypy==1.16.1 ; implementation_name == "cpython"
# via -r requirements/lint.in
mypy-extensions==1.1.0
# via mypy
nodeenv==1.9.1
# via pre-commit
packaging==25.0
# via pytest
pathspec==0.12.1
# via mypy
platformdirs==4.3.8
# via virtualenv
pluggy==1.6.0
4 changes: 3 additions & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -61,14 +61,16 @@ multidict==6.4.4
# via
# -r requirements/runtime-deps.in
# yarl
mypy==1.15.0 ; implementation_name == "cpython"
mypy==1.16.1 ; implementation_name == "cpython"
# via -r requirements/test.in
mypy-extensions==1.1.0
# via mypy
packaging==25.0
# via
# gunicorn
# pytest
pathspec==0.12.1
# via mypy
pkgconfig==1.5.5
# via -r requirements/test.in
pluggy==1.6.0
Loading