Skip to content

Commit

Permalink
lint: fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancetnik committed Nov 25, 2024
1 parent a67768c commit 64c22b4
Show file tree
Hide file tree
Showing 26 changed files with 115 additions and 98 deletions.
3 changes: 2 additions & 1 deletion faststream/broker/core/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Iterable,
Mapping,
Optional,
Sequence,
)

from faststream.broker.types import MsgType
Expand All @@ -30,7 +31,7 @@ def __init__(
*,
prefix: str,
dependencies: Iterable["Depends"],
middlewares: Iterable["BrokerMiddleware[MsgType]"],
middlewares: Sequence["BrokerMiddleware[MsgType]"],
parser: Optional["CustomCallable"],
decoder: Optional["CustomCallable"],
include_in_schema: Optional[bool],
Expand Down
2 changes: 1 addition & 1 deletion faststream/broker/core/usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
Doc("Dependencies to apply to all broker subscribers."),
],
middlewares: Annotated[
Iterable["BrokerMiddleware[MsgType]"],
Sequence["BrokerMiddleware[MsgType]"],
Doc("Middlewares to apply to all broker publishers/subscribers."),
],
graceful_timeout: Annotated[
Expand Down
3 changes: 2 additions & 1 deletion faststream/broker/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Callable,
Iterable,
Optional,
Sequence,
)

from faststream.broker.core.abc import ABCBroker
Expand Down Expand Up @@ -64,7 +65,7 @@ def __init__(
# base options
prefix: str,
dependencies: Iterable["Depends"],
middlewares: Iterable["BrokerMiddleware[MsgType]"],
middlewares: Sequence["BrokerMiddleware[MsgType]"],
parser: Optional["CustomCallable"],
decoder: Optional["CustomCallable"],
include_in_schema: Optional[bool],
Expand Down
3 changes: 2 additions & 1 deletion faststream/broker/subscriber/call_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Generic,
Iterable,
Optional,
Sequence,
cast,
)

Expand Down Expand Up @@ -54,7 +55,7 @@ def __init__(
filter: "AsyncFilter[StreamMessage[MsgType]]",
item_parser: Optional["CustomCallable"],
item_decoder: Optional["CustomCallable"],
item_middlewares: Iterable["SubscriberMiddleware[StreamMessage[MsgType]]"],
item_middlewares: Sequence["SubscriberMiddleware[StreamMessage[MsgType]]"],
dependencies: Iterable["Depends"],
) -> None:
self.handler = handler
Expand Down
15 changes: 12 additions & 3 deletions faststream/broker/subscriber/proto.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from abc import abstractmethod
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Sequence,
)

from typing_extensions import Self, override

Expand Down Expand Up @@ -33,7 +42,7 @@ class SubscriberProto(
running: bool

_broker_dependencies: Iterable["Depends"]
_broker_middlewares: Iterable["BrokerMiddleware[MsgType]"]
_broker_middlewares: Sequence["BrokerMiddleware[MsgType]"]
_producer: Optional["ProducerProto"]

@abstractmethod
Expand Down Expand Up @@ -98,6 +107,6 @@ def add_call(
filter_: "Filter[Any]",
parser_: "CustomCallable",
decoder_: "CustomCallable",
middlewares_: Iterable["SubscriberMiddleware[Any]"],
middlewares_: Sequence["SubscriberMiddleware[Any]"],
dependencies_: Iterable["Depends"],
) -> Self: ...
13 changes: 7 additions & 6 deletions faststream/broker/subscriber/usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Iterable,
List,
Optional,
Sequence,
Tuple,
Union,
overload,
Expand Down Expand Up @@ -66,7 +67,7 @@ def __init__(
filter: "Filter[Any]",
parser: Optional["CustomCallable"],
decoder: Optional["CustomCallable"],
middlewares: Iterable["SubscriberMiddleware[Any]"],
middlewares: Sequence["SubscriberMiddleware[Any]"],
dependencies: Iterable["Depends"],
) -> None:
self.filter = filter
Expand Down Expand Up @@ -98,7 +99,7 @@ def __init__(
no_reply: bool,
retry: Union[bool, int],
broker_dependencies: Iterable["Depends"],
broker_middlewares: Iterable["BrokerMiddleware[MsgType]"],
broker_middlewares: Sequence["BrokerMiddleware[MsgType]"],
default_parser: "AsyncCallable",
default_decoder: "AsyncCallable",
# AsyncAPI information
Expand Down Expand Up @@ -211,7 +212,7 @@ def add_call(
filter_: "Filter[Any]",
parser_: Optional["CustomCallable"],
decoder_: Optional["CustomCallable"],
middlewares_: Iterable["SubscriberMiddleware[Any]"],
middlewares_: Sequence["SubscriberMiddleware[Any]"],
dependencies_: Iterable["Depends"],
) -> Self:
self._call_options = _CallOptions(
Expand All @@ -231,7 +232,7 @@ def __call__(
filter: Optional["Filter[Any]"] = None,
parser: Optional["CustomCallable"] = None,
decoder: Optional["CustomCallable"] = None,
middlewares: Iterable["SubscriberMiddleware[Any]"] = (),
middlewares: Sequence["SubscriberMiddleware[Any]"] = (),
dependencies: Iterable["Depends"] = (),
) -> Callable[
[Callable[P_HandlerParams, T_HandlerReturn]],
Expand All @@ -246,7 +247,7 @@ def __call__(
filter: Optional["Filter[Any]"] = None,
parser: Optional["CustomCallable"] = None,
decoder: Optional["CustomCallable"] = None,
middlewares: Iterable["SubscriberMiddleware[Any]"] = (),
middlewares: Sequence["SubscriberMiddleware[Any]"] = (),
dependencies: Iterable["Depends"] = (),
) -> "HandlerCallWrapper[MsgType, P_HandlerParams, T_HandlerReturn]": ...

Expand All @@ -257,7 +258,7 @@ def __call__(
filter: Optional["Filter[Any]"] = None,
parser: Optional["CustomCallable"] = None,
decoder: Optional["CustomCallable"] = None,
middlewares: Iterable["SubscriberMiddleware[Any]"] = (),
middlewares: Sequence["SubscriberMiddleware[Any]"] = (),
dependencies: Iterable["Depends"] = (),
) -> Any:
if (options := self._call_options) is None:
Expand Down
7 changes: 4 additions & 3 deletions faststream/broker/wrapper/proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Iterable,
Optional,
Protocol,
Sequence,
Union,
overload,
)
Expand Down Expand Up @@ -35,7 +36,7 @@ def __call__(
filter: Optional["Filter[Any]"] = None,
parser: Optional["CustomCallable"] = None,
decoder: Optional["CustomCallable"] = None,
middlewares: Iterable["SubscriberMiddleware[Any]"] = (),
middlewares: Sequence["SubscriberMiddleware[Any]"] = (),
dependencies: Iterable["Depends"] = (),
) -> Callable[
[Callable[P_HandlerParams, T_HandlerReturn]],
Expand All @@ -53,7 +54,7 @@ def __call__(
filter: Optional["Filter[Any]"] = None,
parser: Optional["CustomCallable"] = None,
decoder: Optional["CustomCallable"] = None,
middlewares: Iterable["SubscriberMiddleware[Any]"] = (),
middlewares: Sequence["SubscriberMiddleware[Any]"] = (),
dependencies: Iterable["Depends"] = (),
) -> "HandlerCallWrapper[MsgType, P_HandlerParams, T_HandlerReturn]": ...

Expand All @@ -68,7 +69,7 @@ def __call__(
filter: Optional["Filter[Any]"] = None,
parser: Optional["CustomCallable"] = None,
decoder: Optional["CustomCallable"] = None,
middlewares: Iterable["SubscriberMiddleware[Any]"] = (),
middlewares: Sequence["SubscriberMiddleware[Any]"] = (),
dependencies: Iterable["Depends"] = (),
) -> Union[
"HandlerCallWrapper[MsgType, P_HandlerParams, T_HandlerReturn]",
Expand Down
8 changes: 4 additions & 4 deletions faststream/confluent/broker/registrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -577,7 +577,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -859,7 +859,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -1144,7 +1144,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down
6 changes: 3 additions & 3 deletions faststream/confluent/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
] = False,
# basic args
middlewares: Annotated[
Iterable["PublisherMiddleware"],
Sequence["PublisherMiddleware"],
Doc("Publisher middlewares to wrap outgoing messages."),
] = (),
# AsyncAPI args
Expand Down Expand Up @@ -378,7 +378,7 @@ def __init__(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -492,7 +492,7 @@ def __init__(
),
] = (),
middlewares: Annotated[
Iterable[
Sequence[
Union[
"BrokerMiddleware[Message]",
"BrokerMiddleware[Tuple[Message, ...]]",
Expand Down
17 changes: 9 additions & 8 deletions faststream/confluent/subscriber/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_subscriber(
no_reply: bool,
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Iterable["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
broker_middlewares: Sequence["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
# AsyncAPI args
title_: Optional[str],
description_: Optional[str],
Expand All @@ -64,7 +64,7 @@ def create_subscriber(
no_reply: bool,
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Iterable["BrokerMiddleware[ConfluentMsg]"],
broker_middlewares: Sequence["BrokerMiddleware[ConfluentMsg]"],
# AsyncAPI args
title_: Optional[str],
description_: Optional[str],
Expand All @@ -89,8 +89,8 @@ def create_subscriber(
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Union[
Iterable["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
Iterable["BrokerMiddleware[ConfluentMsg]"],
Sequence["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
Sequence["BrokerMiddleware[ConfluentMsg]"],
],
# AsyncAPI args
title_: Optional[str],
Expand Down Expand Up @@ -118,8 +118,8 @@ def create_subscriber(
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Union[
Iterable["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
Iterable["BrokerMiddleware[ConfluentMsg]"],
Sequence["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
Sequence["BrokerMiddleware[ConfluentMsg]"],
],
# AsyncAPI args
title_: Optional[str],
Expand All @@ -143,7 +143,7 @@ def create_subscriber(
retry=retry,
broker_dependencies=broker_dependencies,
broker_middlewares=cast(
Iterable["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
Sequence["BrokerMiddleware[Tuple[ConfluentMsg, ...]]"],
broker_middlewares,
),
title_=title_,
Expand All @@ -163,7 +163,8 @@ def create_subscriber(
retry=retry,
broker_dependencies=broker_dependencies,
broker_middlewares=cast(
Iterable["BrokerMiddleware[ConfluentMsg]"], broker_middlewares
Sequence["BrokerMiddleware[ConfluentMsg]"],
broker_middlewares,
),
title_=title_,
description_=description_,
Expand Down
6 changes: 3 additions & 3 deletions faststream/confluent/subscriber/usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
no_reply: bool,
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Iterable["BrokerMiddleware[MsgType]"],
broker_middlewares: Sequence["BrokerMiddleware[MsgType]"],
# AsyncAPI args
title_: Optional[str],
description_: Optional[str],
Expand Down Expand Up @@ -286,7 +286,7 @@ def __init__(
no_reply: bool,
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Iterable["BrokerMiddleware[Message]"],
broker_middlewares: Sequence["BrokerMiddleware[Message]"],
# AsyncAPI args
title_: Optional[str],
description_: Optional[str],
Expand Down Expand Up @@ -350,7 +350,7 @@ def __init__(
no_reply: bool,
retry: bool,
broker_dependencies: Iterable["Depends"],
broker_middlewares: Iterable["BrokerMiddleware[Tuple[Message, ...]]"],
broker_middlewares: Sequence["BrokerMiddleware[Tuple[Message, ...]]"],
# AsyncAPI args
title_: Optional[str],
description_: Optional[str],
Expand Down
8 changes: 4 additions & 4 deletions faststream/kafka/broker/registrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -785,7 +785,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -1166,7 +1166,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
filter: Annotated[
Expand Down Expand Up @@ -1550,7 +1550,7 @@ def subscriber(
Doc("Function to decode FastStream msg bytes body to python objects."),
] = None,
middlewares: Annotated[
Iterable["SubscriberMiddleware[KafkaMessage]"],
Sequence["SubscriberMiddleware[KafkaMessage]"],
Doc("Subscriber middlewares to wrap incoming message processing."),
] = (),
max_workers: Annotated[
Expand Down
4 changes: 2 additions & 2 deletions faststream/kafka/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(
] = False,
# basic args
middlewares: Annotated[
Iterable["PublisherMiddleware"],
Sequence["PublisherMiddleware"],
Doc("Publisher middlewares to wrap outgoing messages."),
] = (),
# AsyncAPI args
Expand Down Expand Up @@ -607,7 +607,7 @@ def __init__(
),
] = (),
middlewares: Annotated[
Iterable[
Sequence[
Union[
"BrokerMiddleware[ConsumerRecord]",
"BrokerMiddleware[Tuple[ConsumerRecord, ...]]",
Expand Down
Loading

0 comments on commit 64c22b4

Please sign in to comment.