File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -316,15 +316,14 @@ def filter(
316316 """
317317 ... # pylint: disable=unnecessary-ellipsis
318318
319- # We need to use Any here because otherwise _Filter would have to deal with two
320- # different signatures. We can create two filter classes, one for regular functions
321- # and one for type guards, but then there is no way to tell at runtime which
322- # function is a type guard and which isn't to instantiate the correct class.
323- # Using Any here has no impact though, as thanks to the overloads, only the
324- # overloaded types will be accepted.
325319 def filter (
326- self , filter_function : Callable [[ReceiverMessageT_co ], Any ], /
327- ) -> Receiver [Any ]:
320+ self ,
321+ filter_function : (
322+ Callable [[ReceiverMessageT_co ], bool ]
323+ | Callable [[ReceiverMessageT_co ], TypeGuard [FilteredMessageT_co ]]
324+ ),
325+ / ,
326+ ) -> Receiver [ReceiverMessageT_co ] | Receiver [FilteredMessageT_co ]:
328327 """Apply a filter function on the messages on a receiver.
329328
330329 Note:
You can’t perform that action at this time.
0 commit comments