2
0

mypy: enable warn_return_any

This commit is contained in:
Stefan Bühler 2023-11-15 12:21:51 +01:00
parent fdd38d7498
commit 39191514cc
3 changed files with 25 additions and 6 deletions

View File

@ -10,7 +10,7 @@ python_version = "3.11"
# disallow_any_generics = true # disallow_any_generics = true
# disallow_untyped_defs = true # disallow_untyped_defs = true
# warn_redundant_casts = true # warn_redundant_casts = true
# warn_return_any = true warn_return_any = true
warn_unused_configs = true warn_unused_configs = true
# warn_unused_ignores = true # warn_unused_ignores = true
# warn_unreachable = true # warn_unreachable = true

View File

@ -67,7 +67,10 @@ def local_proxy_fix(request: quart.Request):
class LocalProxyFixRequestHandler: class LocalProxyFixRequestHandler:
def __init__(self, orig_handle_request): def __init__(
self,
orig_handle_request: typing.Callable[[quart.Request], typing.Awaitable[quart.Response | werkzeug.Response]],
):
self._orig_handle_request = orig_handle_request self._orig_handle_request = orig_handle_request
async def __call__(self, request: quart.Request) -> quart.Response | werkzeug.Response: async def __call__(self, request: quart.Request) -> quart.Response | werkzeug.Response:

View File

@ -50,7 +50,7 @@ _monkey_patch_pyroute2()
def _build(msg_class: type[_NlMsgBase], /, attrs: dict = {}, header: dict = {}, **fields) -> _NlMsgBase: def _build(msg_class: type[_NlMsgBase], /, attrs: dict = {}, header: dict = {}, **fields) -> _NlMsgBase:
msg = msg_class() msg: _NlMsgBase = msg_class()
for key, value in header.items(): for key, value in header.items():
msg["header"][key] = value msg["header"][key] = value
for key, value in fields.items(): for key, value in fields.items():
@ -102,16 +102,32 @@ class NFTSocket(pyroute2.netlink.nlsocket.NetlinkSocket):
with self.begin() as tx: with self.begin() as tx:
tx.put(msg_type, msg_flags, attrs=attrs, **fields) tx.put(msg_type, msg_flags, attrs=attrs, **fields)
def nft_dump(self, msg_type: int, msg_flags: int = 0, /, *, attrs: dict = {}, **fields) -> None: def nft_dump(
self,
msg_type: int,
msg_flags: int = 0,
/,
*,
attrs: dict = {},
**fields,
) -> typing.Iterator[nfgen_msg]:
msg_flags |= pyroute2.netlink.NLM_F_DUMP msg_flags |= pyroute2.netlink.NLM_F_DUMP
return self.nft_get(msg_type, msg_flags, attrs=attrs, **fields) return self.nft_get(msg_type, msg_flags, attrs=attrs, **fields)
def nft_get(self, msg_type: int, msg_flags: int = 0, /, *, attrs: dict = {}, **fields) -> None: def nft_get(
self,
msg_type: int,
msg_flags: int = 0,
/,
*,
attrs: dict = {},
**fields,
) -> typing.Iterator[nfgen_msg]:
msg_class: type[_nftsocket.nft_gen_msg] = self.policy[msg_type] msg_class: type[_nftsocket.nft_gen_msg] = self.policy[msg_type]
msg_type = (NFNL_SUBSYS_NFTABLES << 8) | msg_type msg_type = (NFNL_SUBSYS_NFTABLES << 8) | msg_type
msg_flags |= pyroute2.netlink.NLM_F_REQUEST msg_flags |= pyroute2.netlink.NLM_F_REQUEST
msg = _build(msg_class, attrs=attrs, **fields) msg = _build(msg_class, attrs=attrs, **fields)
return self.nlm_request(msg, msg_type, msg_flags) return self.nlm_request(msg, msg_type, msg_flags) # type: ignore
class NFTTransaction: class NFTTransaction: