Skip to content

Commit 7b77366

Browse files
committed
narrow the unecessary Any hints
1 parent 379d8eb commit 7b77366

13 files changed

Lines changed: 176 additions & 133 deletions

File tree

streamable/_afunctions.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from inspect import iscoroutinefunction
55
from operator import itemgetter
66
from typing import (
7-
Any,
87
AsyncIterable,
98
AsyncIterator,
109
Callable,
@@ -43,9 +42,9 @@ def catch(
4342
aiterator: AsyncIterator[T],
4443
errors: Union[Type[Exc], Tuple[Type[Exc], ...]],
4544
*,
46-
where: Optional[Union[Callable[[Exc], Any], AsyncFunction[Exc, Any]]] = None,
45+
where: Optional[Union[Callable[[Exc], object], AsyncFunction[Exc, object]]] = None,
4746
replace: Optional[Union[Callable[[Exc], U], AsyncFunction[Exc, U]]] = None,
48-
do: Optional[Union[Callable[[Exc], Any], AsyncFunction[Exc, Any]]] = None,
47+
do: Optional[Union[Callable[[Exc], object], AsyncFunction[Exc, object]]] = None,
4948
stop: bool = False,
5049
) -> AsyncIterator[Union[T, U]]:
5150
return _aiterators.CatchAsyncIterator(
@@ -59,7 +58,7 @@ def catch(
5958

6059

6160
def filter(
62-
where: Union[Callable[[T], Any], AsyncFunction[T, Any]],
61+
where: Union[Callable[[T], object], AsyncFunction[T, object]],
6362
aiterator: AsyncIterator[T],
6463
) -> AsyncIterator[T]:
6564
return _aiterators.FilterAsyncIterator(aiterator, asyncify(where))
@@ -138,8 +137,8 @@ def observe(
138137
subject: str,
139138
every: Union[None, int, datetime.timedelta],
140139
do: Union[
141-
Callable[[Observation], Any],
142-
AsyncFunction[Observation, Any],
140+
Callable[[Observation], object],
141+
AsyncFunction[Observation, object],
143142
],
144143
) -> AsyncIterator[T]:
145144
if every is None:
@@ -155,7 +154,7 @@ def observe(
155154

156155
def skip(
157156
aiterator: AsyncIterator[T],
158-
until: Union[int, Callable[[T], Any], AsyncFunction[T, Any]],
157+
until: Union[int, Callable[[T], object], AsyncFunction[T, object]],
159158
) -> AsyncIterator[T]:
160159
if isinstance(until, int):
161160
return _aiterators.CountSkipAsyncIterator(aiterator, until)
@@ -164,7 +163,7 @@ def skip(
164163

165164
def take(
166165
aiterator: AsyncIterator[T],
167-
until: Union[int, Callable[[T], Any], AsyncFunction[T, Any]],
166+
until: Union[int, Callable[[T], object], AsyncFunction[T, object]],
168167
) -> AsyncIterator[T]:
169168
if isinstance(until, int):
170169
return _aiterators.CountTakeAsyncIterator(aiterator, until)

streamable/_aiterators.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from collections import defaultdict, deque
88
from concurrent.futures import Executor, ThreadPoolExecutor
99
from typing import (
10-
Any,
1110
AsyncIterable,
1211
AsyncIterator,
1312
Awaitable,
@@ -133,9 +132,9 @@ def __init__(
133132
self,
134133
iterator: AsyncIterator[T],
135134
errors: Union[Type[Exc], Tuple[Type[Exc], ...]],
136-
where: Optional[AsyncFunction[Exc, Any]],
135+
where: Optional[AsyncFunction[Exc, object]],
137136
replace: Optional[AsyncFunction[Exc, U]],
138-
do: Optional[AsyncFunction[Exc, Any]],
137+
do: Optional[AsyncFunction[Exc, object]],
139138
stop: bool,
140139
) -> None:
141140
self.iterator = iterator
@@ -434,7 +433,7 @@ class PredicateSkipAsyncIterator(AsyncIterator[T]):
434433
__slots__ = ("iterator", "until", "_satisfied")
435434

436435
def __init__(
437-
self, iterator: AsyncIterator[T], until: AsyncFunction[T, Any]
436+
self, iterator: AsyncIterator[T], until: AsyncFunction[T, object]
438437
) -> None:
439438
self.iterator = iterator
440439
self.until = until
@@ -473,7 +472,7 @@ class PredicateTakeAsyncIterator(AsyncIterator[T]):
473472
__slots__ = ("iterator", "until", "_satisfied")
474473

475474
def __init__(
476-
self, iterator: AsyncIterator[T], until: AsyncFunction[T, Any]
475+
self, iterator: AsyncIterator[T], until: AsyncFunction[T, object]
477476
) -> None:
478477
self.iterator = iterator
479478
self.until = until
@@ -520,7 +519,7 @@ class FilterAsyncIterator(AsyncIterator[T]):
520519
def __init__(
521520
self,
522521
iterator: AsyncIterator[T],
523-
where: AsyncFunction[T, Any],
522+
where: AsyncFunction[T, object],
524523
) -> None:
525524
self.iterator = iterator
526525
self.where = where
@@ -555,7 +554,7 @@ def __init__(
555554
self,
556555
iterator: AsyncIterator[T],
557556
subject: str,
558-
do: AsyncFunction[Observation, Any],
557+
do: AsyncFunction[Observation, object],
559558
) -> None:
560559
self.iterator = iterator
561560
self.subject = subject
@@ -626,7 +625,7 @@ def __init__(
626625
self,
627626
iterator: AsyncIterator[T],
628627
subject: str,
629-
do: AsyncFunction[Observation, Any],
628+
do: AsyncFunction[Observation, object],
630629
base: int = 2,
631630
) -> None:
632631
super().__init__(iterator, subject, do)
@@ -644,7 +643,7 @@ def __init__(
644643
iterator: AsyncIterator[T],
645644
subject: str,
646645
every: int,
647-
do: AsyncFunction[Observation, Any],
646+
do: AsyncFunction[Observation, object],
648647
) -> None:
649648
super().__init__(iterator, subject, do)
650649
self.every = every
@@ -665,7 +664,7 @@ def __init__(
665664
iterator: AsyncIterator[T],
666665
subject: str,
667666
every: datetime.timedelta,
668-
do: AsyncFunction[Observation, Any],
667+
do: AsyncFunction[Observation, object],
669668
) -> None:
670669
super().__init__(iterator, subject, do)
671670
self.every = every

streamable/_functions.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from contextlib import suppress
55
from operator import itemgetter
66
from typing import (
7-
Any,
87
Callable,
98
Iterable,
109
Iterator,
@@ -40,9 +39,9 @@ def catch(
4039
iterator: Iterator[T],
4140
errors: Union[Type[Exc], Tuple[Type[Exc], ...]],
4241
*,
43-
where: Optional[Union[Callable[[Exc], Any]]] = None,
42+
where: Optional[Union[Callable[[Exc], object]]] = None,
4443
replace: Optional[Union[Callable[[Exc], U]]] = None,
45-
do: Optional[Union[Callable[[Exc], Any]]] = None,
44+
do: Optional[Union[Callable[[Exc], object]]] = None,
4645
stop: bool = False,
4746
) -> Iterator[Union[T, U]]:
4847
return _iterators.CatchIterator(
@@ -56,7 +55,7 @@ def catch(
5655

5756

5857
def filter(
59-
where: Union[Callable[[T], Any]],
58+
where: Union[Callable[[T], object]],
6059
iterator: Iterator[T],
6160
) -> Iterator[T]:
6261
return builtins.filter(where, iterator)
@@ -120,7 +119,7 @@ def observe(
120119
iterator: Iterator[T],
121120
subject: str,
122121
every: Union[None, int, datetime.timedelta],
123-
do: Union[Callable[[Observation], Any],],
122+
do: Union[Callable[[Observation], object],],
124123
) -> Iterator[T]:
125124
if every is None:
126125
return _iterators.PowerObserveIterator(iterator, subject, do)
@@ -131,7 +130,7 @@ def observe(
131130

132131
def skip(
133132
iterator: Iterator[T],
134-
until: Union[int, Callable[[T], Any]],
133+
until: Union[int, Callable[[T], object]],
135134
) -> Iterator[T]:
136135
if isinstance(until, int):
137136
return _iterators.CountSkipIterator(iterator, until)
@@ -140,7 +139,7 @@ def skip(
140139

141140
def take(
142141
iterator: Iterator[T],
143-
until: Union[int, Callable[[T], Any]],
142+
until: Union[int, Callable[[T], object]],
144143
) -> Iterator[T]:
145144
if isinstance(until, int):
146145
return _iterators.CountTakeIterator(iterator, until)

streamable/_iterators.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from concurrent.futures import Executor, Future, ThreadPoolExecutor
99
from contextlib import suppress
1010
from typing import (
11-
Any,
1211
Callable,
1312
ContextManager,
1413
Deque,
@@ -117,9 +116,9 @@ def __init__(
117116
self,
118117
iterator: Iterator[T],
119118
errors: Union[Type[Exc], Tuple[Type[Exc], ...]],
120-
where: Optional[Callable[[Exc], Any]],
119+
where: Optional[Callable[[Exc], object]],
121120
replace: Optional[Callable[[Exc], U]],
122-
do: Optional[Callable[[Exc], Any]],
121+
do: Optional[Callable[[Exc], object]],
123122
stop: bool,
124123
) -> None:
125124
self.iterator = iterator
@@ -391,7 +390,7 @@ def __next__(self) -> T:
391390
class PredicateSkipIterator(Iterator[T]):
392391
__slots__ = ("iterator", "until", "_satisfied")
393392

394-
def __init__(self, iterator: Iterator[T], until: Callable[[T], Any]) -> None:
393+
def __init__(self, iterator: Iterator[T], until: Callable[[T], object]) -> None:
395394
self.iterator = iterator
396395
self.until = until
397396
self._satisfied = False
@@ -428,7 +427,7 @@ def __next__(self) -> T:
428427
class PredicateTakeIterator(Iterator[T]):
429428
__slots__ = ("iterator", "until", "_satisfied")
430429

431-
def __init__(self, iterator: Iterator[T], until: Callable[[T], Any]) -> None:
430+
def __init__(self, iterator: Iterator[T], until: Callable[[T], object]) -> None:
432431
self.iterator = iterator
433432
self.until = until
434433
self._satisfied = False
@@ -466,7 +465,7 @@ def __init__(
466465
self,
467466
iterator: Iterator[T],
468467
subject: str,
469-
do: Callable[[Observation], Any],
468+
do: Callable[[Observation], object],
470469
) -> None:
471470
self.iterator = iterator
472471
self.subject = subject
@@ -537,7 +536,7 @@ def __init__(
537536
self,
538537
iterator: Iterator[T],
539538
subject: str,
540-
do: Callable[[Observation], Any],
539+
do: Callable[[Observation], object],
541540
base: int = 2,
542541
) -> None:
543542
super().__init__(iterator, subject, do)
@@ -555,7 +554,7 @@ def __init__(
555554
iterator: Iterator[T],
556555
subject: str,
557556
every: int,
558-
do: Callable[[Observation], Any],
557+
do: Callable[[Observation], object],
559558
) -> None:
560559
super().__init__(iterator, subject, do)
561560
self.every = every
@@ -576,7 +575,7 @@ def __init__(
576575
iterator: Iterator[T],
577576
subject: str,
578577
every: datetime.timedelta,
579-
do: Callable[[Observation], Any],
578+
do: Callable[[Observation], object],
580579
) -> None:
581580
super().__init__(iterator, subject, do)
582581
self.every = every

0 commit comments

Comments
 (0)