reactivex 4.1.0__py3-none-any.whl → 5.0.0a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reactivex/__init__.py +35 -39
- reactivex/_version.py +1 -1
- reactivex/abc/disposable.py +3 -4
- reactivex/abc/observable.py +13 -6
- reactivex/abc/observer.py +2 -1
- reactivex/abc/periodicscheduler.py +7 -6
- reactivex/abc/scheduler.py +10 -9
- reactivex/abc/subject.py +5 -5
- reactivex/disposable/compositedisposable.py +4 -4
- reactivex/disposable/disposable.py +1 -2
- reactivex/disposable/multipleassignmentdisposable.py +2 -3
- reactivex/disposable/refcountdisposable.py +1 -2
- reactivex/disposable/serialdisposable.py +4 -5
- reactivex/disposable/singleassignmentdisposable.py +3 -4
- reactivex/internal/__init__.py +2 -0
- reactivex/internal/basic.py +2 -2
- reactivex/internal/concurrency.py +2 -1
- reactivex/internal/curry.py +59 -0
- reactivex/internal/exceptions.py +7 -12
- reactivex/internal/priorityqueue.py +2 -2
- reactivex/internal/utils.py +3 -2
- reactivex/notification.py +22 -21
- reactivex/observable/case.py +5 -6
- reactivex/observable/catch.py +3 -2
- reactivex/observable/combinelatest.py +4 -5
- reactivex/observable/concat.py +3 -2
- reactivex/observable/connectableobservable.py +7 -7
- reactivex/observable/defer.py +4 -3
- reactivex/observable/empty.py +3 -4
- reactivex/observable/forkjoin.py +5 -5
- reactivex/observable/fromcallback.py +4 -3
- reactivex/observable/fromfuture.py +2 -2
- reactivex/observable/fromiterable.py +4 -3
- reactivex/observable/generate.py +2 -2
- reactivex/observable/generatewithrelativetime.py +4 -3
- reactivex/observable/groupedobservable.py +4 -4
- reactivex/observable/ifthen.py +3 -2
- reactivex/observable/interval.py +1 -4
- reactivex/observable/marbles.py +18 -17
- reactivex/observable/mixins/__init__.py +32 -0
- reactivex/observable/mixins/combination.py +481 -0
- reactivex/observable/mixins/conditional.py +135 -0
- reactivex/observable/mixins/error_handling.py +130 -0
- reactivex/observable/mixins/filtering.py +1119 -0
- reactivex/observable/mixins/mathematical.py +277 -0
- reactivex/observable/mixins/multicasting.py +306 -0
- reactivex/observable/mixins/testing.py +193 -0
- reactivex/observable/mixins/time_based.py +209 -0
- reactivex/observable/mixins/transformation.py +632 -0
- reactivex/observable/mixins/utility.py +811 -0
- reactivex/observable/mixins/windowing.py +688 -0
- reactivex/observable/never.py +2 -2
- reactivex/observable/observable.py +72 -25
- reactivex/observable/onerrorresumenext.py +7 -6
- reactivex/observable/range.py +6 -6
- reactivex/observable/repeat.py +2 -2
- reactivex/observable/returnvalue.py +6 -5
- reactivex/observable/start.py +3 -2
- reactivex/observable/startasync.py +2 -1
- reactivex/observable/throw.py +3 -3
- reactivex/observable/timer.py +12 -12
- reactivex/observable/toasync.py +3 -2
- reactivex/observable/using.py +5 -4
- reactivex/observable/withlatestfrom.py +4 -5
- reactivex/observable/zip.py +7 -6
- reactivex/observer/autodetachobserver.py +4 -4
- reactivex/observer/observer.py +5 -4
- reactivex/observer/scheduledobserver.py +2 -2
- reactivex/operators/__init__.py +162 -208
- reactivex/operators/_all.py +23 -6
- reactivex/operators/_amb.py +88 -75
- reactivex/operators/_asobservable.py +20 -17
- reactivex/operators/_average.py +48 -45
- reactivex/operators/_buffer.py +81 -35
- reactivex/operators/_bufferwithtime.py +29 -9
- reactivex/operators/_bufferwithtimeorcount.py +27 -8
- reactivex/operators/_catch.py +33 -32
- reactivex/operators/_combinelatest.py +28 -20
- reactivex/operators/_concat.py +16 -13
- reactivex/operators/_contains.py +25 -6
- reactivex/operators/_count.py +24 -8
- reactivex/operators/_debounce.py +141 -138
- reactivex/operators/_defaultifempty.py +45 -42
- reactivex/operators/_delay.py +24 -23
- reactivex/operators/_delaysubscription.py +23 -21
- reactivex/operators/_delaywithmapper.py +10 -11
- reactivex/operators/_dematerialize.py +25 -21
- reactivex/operators/_distinct.py +50 -46
- reactivex/operators/_distinctuntilchanged.py +60 -57
- reactivex/operators/_do.py +123 -116
- reactivex/operators/_dowhile.py +3 -2
- reactivex/operators/_elementatordefault.py +57 -33
- reactivex/operators/_exclusive.py +59 -53
- reactivex/operators/_expand.py +82 -77
- reactivex/operators/_filter.py +63 -68
- reactivex/operators/_finallyaction.py +3 -2
- reactivex/operators/_find.py +49 -32
- reactivex/operators/_first.py +18 -11
- reactivex/operators/_firstordefault.py +5 -4
- reactivex/operators/_flatmap.py +89 -83
- reactivex/operators/_forkjoin.py +23 -18
- reactivex/operators/_groupby.py +27 -6
- reactivex/operators/_groupbyuntil.py +8 -5
- reactivex/operators/_groupjoin.py +7 -6
- reactivex/operators/_ignoreelements.py +20 -15
- reactivex/operators/_isempty.py +15 -4
- reactivex/operators/_join.py +6 -5
- reactivex/operators/_last.py +36 -31
- reactivex/operators/_lastordefault.py +8 -8
- reactivex/operators/_map.py +54 -39
- reactivex/operators/_materialize.py +30 -31
- reactivex/operators/_max.py +18 -11
- reactivex/operators/_maxby.py +5 -5
- reactivex/operators/_merge.py +132 -129
- reactivex/operators/_min.py +16 -10
- reactivex/operators/_minby.py +9 -8
- reactivex/operators/_multicast.py +9 -9
- reactivex/operators/_observeon.py +35 -31
- reactivex/operators/_onerrorresumenext.py +2 -1
- reactivex/operators/_pairwise.py +38 -34
- reactivex/operators/_partition.py +80 -73
- reactivex/operators/_pluck.py +4 -3
- reactivex/operators/_publish.py +36 -21
- reactivex/operators/_publishvalue.py +8 -7
- reactivex/operators/_reduce.py +16 -12
- reactivex/operators/_repeat.py +33 -30
- reactivex/operators/_replay.py +9 -9
- reactivex/operators/_retry.py +12 -10
- reactivex/operators/_sample.py +31 -27
- reactivex/operators/_scan.py +41 -39
- reactivex/operators/_sequenceequal.py +8 -7
- reactivex/operators/_single.py +20 -13
- reactivex/operators/_singleordefault.py +6 -5
- reactivex/operators/_skip.py +35 -32
- reactivex/operators/_skiplast.py +38 -34
- reactivex/operators/_skiplastwithtime.py +5 -4
- reactivex/operators/_skipuntil.py +40 -35
- reactivex/operators/_skipuntilwithtime.py +4 -3
- reactivex/operators/_skipwhile.py +65 -44
- reactivex/operators/_skipwithtime.py +50 -46
- reactivex/operators/_slice.py +58 -53
- reactivex/operators/_some.py +48 -47
- reactivex/operators/_startswith.py +17 -15
- reactivex/operators/_subscribeon.py +44 -41
- reactivex/operators/_sum.py +23 -6
- reactivex/operators/_switchlatest.py +71 -69
- reactivex/operators/_take.py +37 -33
- reactivex/operators/_takelast.py +37 -36
- reactivex/operators/_takelastbuffer.py +38 -37
- reactivex/operators/_takelastwithtime.py +60 -56
- reactivex/operators/_takeuntil.py +33 -32
- reactivex/operators/_takeuntilwithtime.py +42 -39
- reactivex/operators/_takewhile.py +108 -100
- reactivex/operators/_takewithtime.py +46 -41
- reactivex/operators/_throttlefirst.py +52 -45
- reactivex/operators/_timeinterval.py +40 -36
- reactivex/operators/_timeout.py +81 -79
- reactivex/operators/_timeoutwithmapper.py +6 -5
- reactivex/operators/_timestamp.py +24 -22
- reactivex/operators/_todict.py +51 -43
- reactivex/operators/_tofuture.py +24 -15
- reactivex/operators/_toiterable.py +33 -27
- reactivex/operators/_tomarbles.py +5 -5
- reactivex/operators/_toset.py +29 -19
- reactivex/operators/_whiledo.py +2 -1
- reactivex/operators/_window.py +100 -99
- reactivex/operators/_windowwithcount.py +56 -54
- reactivex/operators/_windowwithtime.py +95 -79
- reactivex/operators/_windowwithtimeorcount.py +85 -69
- reactivex/operators/_withlatestfrom.py +13 -9
- reactivex/operators/_zip.py +67 -63
- reactivex/operators/connectable/_refcount.py +4 -3
- reactivex/pipe.py +2 -1
- reactivex/run.py +8 -4
- reactivex/scheduler/catchscheduler.py +11 -10
- reactivex/scheduler/currentthreadscheduler.py +2 -3
- reactivex/scheduler/eventloop/asyncioscheduler.py +7 -6
- reactivex/scheduler/eventloop/asynciothreadsafescheduler.py +12 -14
- reactivex/scheduler/eventloop/eventletscheduler.py +4 -4
- reactivex/scheduler/eventloop/geventscheduler.py +4 -4
- reactivex/scheduler/eventloop/ioloopscheduler.py +4 -4
- reactivex/scheduler/eventloop/twistedscheduler.py +4 -4
- reactivex/scheduler/eventloopscheduler.py +9 -12
- reactivex/scheduler/historicalscheduler.py +1 -2
- reactivex/scheduler/immediatescheduler.py +5 -4
- reactivex/scheduler/mainloop/gtkscheduler.py +6 -7
- reactivex/scheduler/mainloop/pygamescheduler.py +4 -4
- reactivex/scheduler/mainloop/qtscheduler.py +6 -6
- reactivex/scheduler/mainloop/tkinterscheduler.py +4 -4
- reactivex/scheduler/mainloop/wxscheduler.py +7 -7
- reactivex/scheduler/newthreadscheduler.py +6 -8
- reactivex/scheduler/periodicscheduler.py +4 -4
- reactivex/scheduler/scheduleditem.py +4 -4
- reactivex/scheduler/scheduler.py +5 -5
- reactivex/scheduler/threadpoolscheduler.py +3 -3
- reactivex/scheduler/timeoutscheduler.py +5 -4
- reactivex/scheduler/trampoline.py +1 -2
- reactivex/scheduler/trampolinescheduler.py +5 -6
- reactivex/scheduler/virtualtimescheduler.py +4 -4
- reactivex/subject/asyncsubject.py +2 -2
- reactivex/subject/behaviorsubject.py +2 -2
- reactivex/subject/innersubscription.py +2 -2
- reactivex/subject/replaysubject.py +8 -8
- reactivex/subject/subject.py +4 -4
- reactivex/testing/coldobservable.py +5 -5
- reactivex/testing/hotobservable.py +6 -6
- reactivex/testing/marbles.py +21 -20
- reactivex/testing/mockdisposable.py +1 -3
- reactivex/testing/mockobserver.py +2 -2
- reactivex/testing/reactivetest.py +2 -2
- reactivex/testing/recorded.py +1 -1
- reactivex/testing/subscription.py +3 -3
- reactivex/testing/testscheduler.py +13 -12
- reactivex/typing.py +25 -14
- {reactivex-4.1.0.dist-info → reactivex-5.0.0a2.dist-info}/METADATA +59 -26
- reactivex-5.0.0a2.dist-info/RECORD +236 -0
- {reactivex-4.1.0.dist-info → reactivex-5.0.0a2.dist-info}/WHEEL +1 -1
- reactivex-4.1.0.dist-info/RECORD +0 -223
- {reactivex-4.1.0.dist-info → reactivex-5.0.0a2.dist-info}/licenses/LICENSE +0 -0
reactivex/__init__.py
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
# pylint: disable=too-many-lines,redefined-outer-name,redefined-builtin
|
|
2
2
|
|
|
3
3
|
from asyncio import Future
|
|
4
|
+
from collections.abc import Callable, Iterable, Mapping
|
|
4
5
|
from typing import (
|
|
5
6
|
Any,
|
|
6
|
-
Callable,
|
|
7
|
-
Iterable,
|
|
8
|
-
Mapping,
|
|
9
|
-
Optional,
|
|
10
|
-
Tuple,
|
|
11
7
|
TypeVar,
|
|
12
8
|
Union,
|
|
13
9
|
overload,
|
|
@@ -68,7 +64,7 @@ def amb(*sources: Observable[_T]) -> Observable[_T]:
|
|
|
68
64
|
def case(
|
|
69
65
|
mapper: Callable[[], _TKey],
|
|
70
66
|
sources: Mapping[_TKey, Observable[_T]],
|
|
71
|
-
default_source:
|
|
67
|
+
default_source: Observable[_T] | Future[_T] | None = None,
|
|
72
68
|
) -> Observable[_T]:
|
|
73
69
|
"""Uses mapper to determine which source in sources to use.
|
|
74
70
|
|
|
@@ -185,19 +181,19 @@ def create(subscribe: typing.Subscription[_T]) -> Observable[_T]:
|
|
|
185
181
|
@overload
|
|
186
182
|
def combine_latest(
|
|
187
183
|
__a: Observable[_A], __b: Observable[_B]
|
|
188
|
-
) -> Observable[
|
|
184
|
+
) -> Observable[tuple[_A, _B]]: ...
|
|
189
185
|
|
|
190
186
|
|
|
191
187
|
@overload
|
|
192
188
|
def combine_latest(
|
|
193
189
|
__a: Observable[_A], __b: Observable[_B], __c: Observable[_C]
|
|
194
|
-
) -> Observable[
|
|
190
|
+
) -> Observable[tuple[_A, _B, _C]]: ...
|
|
195
191
|
|
|
196
192
|
|
|
197
193
|
@overload
|
|
198
194
|
def combine_latest(
|
|
199
195
|
__a: Observable[_A], __b: Observable[_B], __c: Observable[_C], __d: Observable[_D]
|
|
200
|
-
) -> Observable[
|
|
196
|
+
) -> Observable[tuple[_A, _B, _C, _D]]: ...
|
|
201
197
|
|
|
202
198
|
|
|
203
199
|
def combine_latest(*__sources: Observable[Any]) -> Observable[Any]:
|
|
@@ -317,7 +313,7 @@ def defer(
|
|
|
317
313
|
return defer_(factory)
|
|
318
314
|
|
|
319
315
|
|
|
320
|
-
def empty(scheduler:
|
|
316
|
+
def empty(scheduler: abc.SchedulerBase | None = None) -> Observable[Any]:
|
|
321
317
|
"""Returns an empty observable sequence.
|
|
322
318
|
|
|
323
319
|
.. marble::
|
|
@@ -381,19 +377,19 @@ def for_in(
|
|
|
381
377
|
@overload
|
|
382
378
|
def fork_join(
|
|
383
379
|
__a: Observable[_A], __b: Observable[_B]
|
|
384
|
-
) -> Observable[
|
|
380
|
+
) -> Observable[tuple[_A, _B]]: ...
|
|
385
381
|
|
|
386
382
|
|
|
387
383
|
@overload
|
|
388
384
|
def fork_join(
|
|
389
385
|
__a: Observable[_A], __b: Observable[_B], __c: Observable[_C]
|
|
390
|
-
) -> Observable[
|
|
386
|
+
) -> Observable[tuple[_A, _B, _C]]: ...
|
|
391
387
|
|
|
392
388
|
|
|
393
389
|
@overload
|
|
394
390
|
def fork_join(
|
|
395
391
|
__a: Observable[_A], __b: Observable[_B], __c: Observable[_C], __d: Observable[_D]
|
|
396
|
-
) -> Observable[
|
|
392
|
+
) -> Observable[tuple[_A, _B, _C, _D]]: ...
|
|
397
393
|
|
|
398
394
|
|
|
399
395
|
@overload
|
|
@@ -403,7 +399,7 @@ def fork_join(
|
|
|
403
399
|
__c: Observable[_C],
|
|
404
400
|
__d: Observable[_D],
|
|
405
401
|
__e: Observable[_E],
|
|
406
|
-
) -> Observable[
|
|
402
|
+
) -> Observable[tuple[_A, _B, _C, _D, _E]]: ...
|
|
407
403
|
|
|
408
404
|
|
|
409
405
|
def fork_join(*sources: Observable[Any]) -> Observable[Any]:
|
|
@@ -437,7 +433,7 @@ def fork_join(*sources: Observable[Any]) -> Observable[Any]:
|
|
|
437
433
|
|
|
438
434
|
|
|
439
435
|
def from_callable(
|
|
440
|
-
supplier: Callable[[], _T], scheduler:
|
|
436
|
+
supplier: Callable[[], _T], scheduler: abc.SchedulerBase | None = None
|
|
441
437
|
) -> Observable[_T]:
|
|
442
438
|
"""Returns an observable sequence that contains a single element generated
|
|
443
439
|
by the given supplier, using the specified scheduler to send out observer
|
|
@@ -472,7 +468,7 @@ def from_callable(
|
|
|
472
468
|
|
|
473
469
|
def from_callback(
|
|
474
470
|
func: Callable[..., Callable[..., None]],
|
|
475
|
-
mapper:
|
|
471
|
+
mapper: typing.Mapper[Any, Any] | None = None,
|
|
476
472
|
) -> Callable[[], Observable[Any]]:
|
|
477
473
|
"""Converts a callback function to an observable sequence.
|
|
478
474
|
|
|
@@ -516,7 +512,7 @@ def from_future(future: "Future[_T]") -> Observable[_T]:
|
|
|
516
512
|
|
|
517
513
|
|
|
518
514
|
def from_iterable(
|
|
519
|
-
iterable: Iterable[_T], scheduler:
|
|
515
|
+
iterable: Iterable[_T], scheduler: abc.SchedulerBase | None = None
|
|
520
516
|
) -> Observable[_T]:
|
|
521
517
|
"""Converts an iterable to an observable sequence.
|
|
522
518
|
|
|
@@ -555,9 +551,9 @@ from_list = alias(
|
|
|
555
551
|
def from_marbles(
|
|
556
552
|
string: str,
|
|
557
553
|
timespan: typing.RelativeTime = 0.1,
|
|
558
|
-
scheduler:
|
|
559
|
-
lookup:
|
|
560
|
-
error:
|
|
554
|
+
scheduler: abc.SchedulerBase | None = None,
|
|
555
|
+
lookup: Mapping[str | float, Any] | None = None,
|
|
556
|
+
error: Exception | None = None,
|
|
561
557
|
) -> Observable[Any]:
|
|
562
558
|
"""Convert a marble diagram string to a cold observable sequence, using
|
|
563
559
|
an optional scheduler to enumerate the events.
|
|
@@ -701,9 +697,9 @@ def hot(
|
|
|
701
697
|
string: str,
|
|
702
698
|
timespan: typing.RelativeTime = 0.1,
|
|
703
699
|
duetime: typing.AbsoluteOrRelativeTime = 0.0,
|
|
704
|
-
scheduler:
|
|
705
|
-
lookup:
|
|
706
|
-
error:
|
|
700
|
+
scheduler: abc.SchedulerBase | None = None,
|
|
701
|
+
lookup: Mapping[str | float, Any] | None = None,
|
|
702
|
+
error: Exception | None = None,
|
|
707
703
|
) -> Observable[Any]:
|
|
708
704
|
"""Convert a marble diagram string to a hot observable sequence, using
|
|
709
705
|
an optional scheduler to enumerate the events.
|
|
@@ -812,7 +808,7 @@ def if_then(
|
|
|
812
808
|
|
|
813
809
|
|
|
814
810
|
def interval(
|
|
815
|
-
period: typing.RelativeTime, scheduler:
|
|
811
|
+
period: typing.RelativeTime, scheduler: abc.SchedulerBase | None = None
|
|
816
812
|
) -> Observable[int]:
|
|
817
813
|
"""Returns an observable sequence that produces a value after each period.
|
|
818
814
|
|
|
@@ -914,7 +910,7 @@ def of(*args: _T) -> Observable[_T]:
|
|
|
914
910
|
|
|
915
911
|
def on_error_resume_next(
|
|
916
912
|
*sources: Union[
|
|
917
|
-
Observable[_T], "Future[_T]", Callable[[
|
|
913
|
+
Observable[_T], "Future[_T]", Callable[[Exception | None], Observable[_T]]
|
|
918
914
|
],
|
|
919
915
|
) -> Observable[_T]:
|
|
920
916
|
"""Continues an observable sequence that is terminated normally or
|
|
@@ -947,9 +943,9 @@ def on_error_resume_next(
|
|
|
947
943
|
|
|
948
944
|
def range(
|
|
949
945
|
start: int,
|
|
950
|
-
stop:
|
|
951
|
-
step:
|
|
952
|
-
scheduler:
|
|
946
|
+
stop: int | None = None,
|
|
947
|
+
step: int | None = None,
|
|
948
|
+
scheduler: abc.SchedulerBase | None = None,
|
|
953
949
|
) -> Observable[int]:
|
|
954
950
|
"""Generates an observable sequence of integral numbers within a
|
|
955
951
|
specified range, using the specified scheduler to send out observer
|
|
@@ -986,7 +982,7 @@ def range(
|
|
|
986
982
|
|
|
987
983
|
|
|
988
984
|
def return_value(
|
|
989
|
-
value: _T, scheduler:
|
|
985
|
+
value: _T, scheduler: abc.SchedulerBase | None = None
|
|
990
986
|
) -> Observable[_T]:
|
|
991
987
|
"""Returns an observable sequence that contains a single element,
|
|
992
988
|
using the specified scheduler to send out observer messages.
|
|
@@ -1016,7 +1012,7 @@ def return_value(
|
|
|
1016
1012
|
just = alias("just", "Alias for :func:`reactivex.return_value`.", return_value)
|
|
1017
1013
|
|
|
1018
1014
|
|
|
1019
|
-
def repeat_value(value: _T, repeat_count:
|
|
1015
|
+
def repeat_value(value: _T, repeat_count: int | None = None) -> Observable[_T]:
|
|
1020
1016
|
"""Generates an observable sequence that repeats the given element
|
|
1021
1017
|
the specified number of times.
|
|
1022
1018
|
|
|
@@ -1045,7 +1041,7 @@ def repeat_value(value: _T, repeat_count: Optional[int] = None) -> Observable[_T
|
|
|
1045
1041
|
|
|
1046
1042
|
|
|
1047
1043
|
def start(
|
|
1048
|
-
func: Callable[[], _T], scheduler:
|
|
1044
|
+
func: Callable[[], _T], scheduler: abc.SchedulerBase | None = None
|
|
1049
1045
|
) -> Observable[_T]:
|
|
1050
1046
|
"""Invokes the specified function asynchronously on the specified
|
|
1051
1047
|
scheduler, surfacing the result through an observable sequence.
|
|
@@ -1105,7 +1101,7 @@ def start_async(function_async: Callable[[], "Future[_T]"]) -> Observable[_T]:
|
|
|
1105
1101
|
|
|
1106
1102
|
|
|
1107
1103
|
def throw(
|
|
1108
|
-
exception:
|
|
1104
|
+
exception: str | Exception, scheduler: abc.SchedulerBase | None = None
|
|
1109
1105
|
) -> Observable[Any]:
|
|
1110
1106
|
"""Returns an observable sequence that terminates with an exception,
|
|
1111
1107
|
using the specified scheduler to send out the single OnError message.
|
|
@@ -1136,8 +1132,8 @@ def throw(
|
|
|
1136
1132
|
|
|
1137
1133
|
def timer(
|
|
1138
1134
|
duetime: typing.AbsoluteOrRelativeTime,
|
|
1139
|
-
period:
|
|
1140
|
-
scheduler:
|
|
1135
|
+
period: typing.RelativeTime | None = None,
|
|
1136
|
+
scheduler: abc.SchedulerBase | None = None,
|
|
1141
1137
|
) -> Observable[int]:
|
|
1142
1138
|
"""Returns an observable sequence that produces a value after
|
|
1143
1139
|
duetime has elapsed and then after each period.
|
|
@@ -1175,7 +1171,7 @@ def timer(
|
|
|
1175
1171
|
|
|
1176
1172
|
|
|
1177
1173
|
def to_async(
|
|
1178
|
-
func: Callable[..., _T], scheduler:
|
|
1174
|
+
func: Callable[..., _T], scheduler: abc.SchedulerBase | None = None
|
|
1179
1175
|
) -> Callable[..., Observable[_T]]:
|
|
1180
1176
|
"""Converts the function into an asynchronous function. Each
|
|
1181
1177
|
invocation of the resulting asynchronous function causes an
|
|
@@ -1208,8 +1204,8 @@ def to_async(
|
|
|
1208
1204
|
|
|
1209
1205
|
|
|
1210
1206
|
def using(
|
|
1211
|
-
resource_factory: Callable[[],
|
|
1212
|
-
observable_factory: Callable[[
|
|
1207
|
+
resource_factory: Callable[[], abc.DisposableBase | None],
|
|
1208
|
+
observable_factory: Callable[[abc.DisposableBase | None], Observable[_T]],
|
|
1213
1209
|
) -> Observable[_T]:
|
|
1214
1210
|
"""Constructs an observable sequence that depends on a resource
|
|
1215
1211
|
object, whose lifetime is tied to the resulting observable
|
|
@@ -1232,7 +1228,7 @@ def using(
|
|
|
1232
1228
|
return using_(resource_factory, observable_factory)
|
|
1233
1229
|
|
|
1234
1230
|
|
|
1235
|
-
def with_latest_from(*sources: Observable[Any]) -> Observable[
|
|
1231
|
+
def with_latest_from(*sources: Observable[Any]) -> Observable[tuple[Any, ...]]:
|
|
1236
1232
|
"""Merges the specified observable sequences into one observable
|
|
1237
1233
|
sequence by creating a :class:`tuple` only when the first
|
|
1238
1234
|
observable sequence produces an element.
|
|
@@ -1261,7 +1257,7 @@ def with_latest_from(*sources: Observable[Any]) -> Observable[Tuple[Any, ...]]:
|
|
|
1261
1257
|
return with_latest_from_(*sources)
|
|
1262
1258
|
|
|
1263
1259
|
|
|
1264
|
-
def zip(*args: Observable[Any]) -> Observable[
|
|
1260
|
+
def zip(*args: Observable[Any]) -> Observable[tuple[Any, ...]]:
|
|
1265
1261
|
"""Merges the specified observable sequences into one observable
|
|
1266
1262
|
sequence by creating a :class:`tuple` whenever all of the
|
|
1267
1263
|
observable sequences have produced an element at a corresponding
|
reactivex/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "
|
|
1
|
+
__version__ = "5.0.0a2"
|
reactivex/abc/disposable.py
CHANGED
|
@@ -2,7 +2,6 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
4
|
from types import TracebackType
|
|
5
|
-
from typing import Optional, Type
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
class DisposableBase(ABC):
|
|
@@ -23,9 +22,9 @@ class DisposableBase(ABC):
|
|
|
23
22
|
|
|
24
23
|
def __exit__(
|
|
25
24
|
self,
|
|
26
|
-
exctype:
|
|
27
|
-
excinst:
|
|
28
|
-
exctb:
|
|
25
|
+
exctype: type[BaseException] | None,
|
|
26
|
+
excinst: BaseException | None,
|
|
27
|
+
exctb: TracebackType | None,
|
|
29
28
|
) -> None:
|
|
30
29
|
"""Context management protocol."""
|
|
31
30
|
self.dispose()
|
reactivex/abc/observable.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import Generic, TypeVar
|
|
4
|
+
|
|
5
|
+
from typing_extensions import TypeAliasType
|
|
3
6
|
|
|
4
7
|
from .disposable import DisposableBase
|
|
5
8
|
from .observer import ObserverBase, OnCompleted, OnError, OnNext
|
|
@@ -18,11 +21,11 @@ class ObservableBase(Generic[_T_out], ABC):
|
|
|
18
21
|
@abstractmethod
|
|
19
22
|
def subscribe(
|
|
20
23
|
self,
|
|
21
|
-
on_next:
|
|
22
|
-
on_error:
|
|
23
|
-
on_completed:
|
|
24
|
+
on_next: OnNext[_T_out] | ObserverBase[_T_out] | None = None,
|
|
25
|
+
on_error: OnError | None = None,
|
|
26
|
+
on_completed: OnCompleted | None = None,
|
|
24
27
|
*,
|
|
25
|
-
scheduler:
|
|
28
|
+
scheduler: SchedulerBase | None = None,
|
|
26
29
|
) -> DisposableBase:
|
|
27
30
|
"""Subscribe an observer to the observable sequence.
|
|
28
31
|
|
|
@@ -40,6 +43,10 @@ class ObservableBase(Generic[_T_out], ABC):
|
|
|
40
43
|
raise NotImplementedError
|
|
41
44
|
|
|
42
45
|
|
|
43
|
-
Subscription =
|
|
46
|
+
Subscription = TypeAliasType(
|
|
47
|
+
"Subscription",
|
|
48
|
+
Callable[[ObserverBase[_T_out], SchedulerBase | None], DisposableBase],
|
|
49
|
+
type_params=(_T_out,),
|
|
50
|
+
)
|
|
44
51
|
|
|
45
52
|
__all__ = ["ObservableBase", "Subscription"]
|
reactivex/abc/observer.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import TypeVar
|
|
3
4
|
|
|
4
5
|
from .disposable import DisposableBase
|
|
5
6
|
from .scheduler import RelativeTime, ScheduledAction
|
|
6
7
|
|
|
7
8
|
_TState = TypeVar("_TState") # Can be anything
|
|
8
9
|
|
|
9
|
-
ScheduledPeriodicAction = Callable[[
|
|
10
|
-
ScheduledSingleOrPeriodicAction =
|
|
11
|
-
ScheduledAction[_TState]
|
|
12
|
-
|
|
10
|
+
ScheduledPeriodicAction = Callable[[_TState | None], _TState | None]
|
|
11
|
+
ScheduledSingleOrPeriodicAction = (
|
|
12
|
+
ScheduledAction[_TState] | ScheduledPeriodicAction[_TState]
|
|
13
|
+
)
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class PeriodicSchedulerBase(ABC):
|
|
@@ -22,7 +23,7 @@ class PeriodicSchedulerBase(ABC):
|
|
|
22
23
|
self,
|
|
23
24
|
period: RelativeTime,
|
|
24
25
|
action: ScheduledPeriodicAction[_TState],
|
|
25
|
-
state:
|
|
26
|
+
state: _TState | None = None,
|
|
26
27
|
) -> DisposableBase:
|
|
27
28
|
"""Schedules a periodic piece of work.
|
|
28
29
|
|
reactivex/abc/scheduler.py
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from datetime import datetime, timedelta
|
|
3
|
-
from typing import
|
|
4
|
+
from typing import TypeVar
|
|
4
5
|
|
|
5
6
|
from .disposable import DisposableBase
|
|
6
7
|
|
|
7
8
|
_TState = TypeVar("_TState") # Can be anything
|
|
8
9
|
|
|
9
|
-
AbsoluteTime =
|
|
10
|
-
RelativeTime =
|
|
11
|
-
AbsoluteOrRelativeTime =
|
|
10
|
+
AbsoluteTime = datetime | float
|
|
11
|
+
RelativeTime = timedelta | float
|
|
12
|
+
AbsoluteOrRelativeTime = datetime | timedelta | float
|
|
12
13
|
ScheduledAction = Callable[
|
|
13
|
-
["SchedulerBase",
|
|
14
|
-
|
|
14
|
+
["SchedulerBase", _TState | None],
|
|
15
|
+
DisposableBase | None,
|
|
15
16
|
]
|
|
16
17
|
|
|
17
18
|
|
|
@@ -35,7 +36,7 @@ class SchedulerBase(ABC):
|
|
|
35
36
|
|
|
36
37
|
@abstractmethod
|
|
37
38
|
def schedule(
|
|
38
|
-
self, action: ScheduledAction[_TState], state:
|
|
39
|
+
self, action: ScheduledAction[_TState], state: _TState | None = None
|
|
39
40
|
) -> DisposableBase:
|
|
40
41
|
"""Schedules an action to be executed.
|
|
41
42
|
|
|
@@ -55,7 +56,7 @@ class SchedulerBase(ABC):
|
|
|
55
56
|
self,
|
|
56
57
|
duetime: RelativeTime,
|
|
57
58
|
action: ScheduledAction[_TState],
|
|
58
|
-
state:
|
|
59
|
+
state: _TState | None = None,
|
|
59
60
|
) -> DisposableBase:
|
|
60
61
|
"""Schedules an action to be executed after duetime.
|
|
61
62
|
|
|
@@ -76,7 +77,7 @@ class SchedulerBase(ABC):
|
|
|
76
77
|
self,
|
|
77
78
|
duetime: AbsoluteTime,
|
|
78
79
|
action: ScheduledAction[_TState],
|
|
79
|
-
state:
|
|
80
|
+
state: _TState | None = None,
|
|
80
81
|
) -> DisposableBase:
|
|
81
82
|
"""Schedules an action to be executed at duetime.
|
|
82
83
|
|
reactivex/abc/subject.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from abc import abstractmethod
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import TypeVar
|
|
3
3
|
|
|
4
4
|
from .disposable import DisposableBase
|
|
5
5
|
from .observable import ObservableBase
|
|
@@ -21,11 +21,11 @@ class SubjectBase(ObserverBase[_T], ObservableBase[_T]):
|
|
|
21
21
|
@abstractmethod
|
|
22
22
|
def subscribe(
|
|
23
23
|
self,
|
|
24
|
-
on_next:
|
|
25
|
-
on_error:
|
|
26
|
-
on_completed:
|
|
24
|
+
on_next: OnNext[_T] | ObserverBase[_T] | None = None,
|
|
25
|
+
on_error: OnError | None = None,
|
|
26
|
+
on_completed: OnCompleted | None = None,
|
|
27
27
|
*,
|
|
28
|
-
scheduler:
|
|
28
|
+
scheduler: SchedulerBase | None = None,
|
|
29
29
|
) -> DisposableBase:
|
|
30
30
|
"""Subscribe an observer to the observable sequence.
|
|
31
31
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
|
-
from typing import Any
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
4
|
from reactivex import abc
|
|
5
5
|
|
|
@@ -10,13 +10,13 @@ class CompositeDisposable(abc.DisposableBase):
|
|
|
10
10
|
|
|
11
11
|
def __init__(self, *args: Any):
|
|
12
12
|
if args and isinstance(args[0], list):
|
|
13
|
-
self.disposable:
|
|
13
|
+
self.disposable: list[abc.DisposableBase] = args[0]
|
|
14
14
|
else:
|
|
15
15
|
self.disposable = list(args)
|
|
16
16
|
|
|
17
17
|
self.is_disposed = False
|
|
18
18
|
self.lock = RLock()
|
|
19
|
-
super(
|
|
19
|
+
super().__init__()
|
|
20
20
|
|
|
21
21
|
def add(self, item: abc.DisposableBase) -> None:
|
|
22
22
|
"""Adds a disposable to the CompositeDisposable or disposes the
|
|
@@ -92,7 +92,7 @@ class CompositeDisposable(abc.DisposableBase):
|
|
|
92
92
|
|
|
93
93
|
return item in self.disposable
|
|
94
94
|
|
|
95
|
-
def to_list(self) ->
|
|
95
|
+
def to_list(self) -> list[abc.DisposableBase]:
|
|
96
96
|
return self.disposable[:]
|
|
97
97
|
|
|
98
98
|
def __len__(self) -> int:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from reactivex import typing
|
|
5
4
|
from reactivex.abc import DisposableBase
|
|
@@ -10,7 +9,7 @@ from reactivex.typing import Action
|
|
|
10
9
|
class Disposable(DisposableBase):
|
|
11
10
|
"""Main disposable class"""
|
|
12
11
|
|
|
13
|
-
def __init__(self, action:
|
|
12
|
+
def __init__(self, action: typing.Action | None = None) -> None:
|
|
14
13
|
"""Creates a disposable object that invokes the specified
|
|
15
14
|
action when disposed.
|
|
16
15
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from reactivex.abc import DisposableBase
|
|
5
4
|
|
|
@@ -9,13 +8,13 @@ class MultipleAssignmentDisposable(DisposableBase):
|
|
|
9
8
|
resource can be replaced by another disposable resource."""
|
|
10
9
|
|
|
11
10
|
def __init__(self) -> None:
|
|
12
|
-
self.current:
|
|
11
|
+
self.current: DisposableBase | None = None
|
|
13
12
|
self.is_disposed = False
|
|
14
13
|
self.lock = RLock()
|
|
15
14
|
|
|
16
15
|
super().__init__()
|
|
17
16
|
|
|
18
|
-
def get_disposable(self) ->
|
|
17
|
+
def get_disposable(self) -> DisposableBase | None:
|
|
19
18
|
return self.current
|
|
20
19
|
|
|
21
20
|
def set_disposable(self, value: DisposableBase) -> None:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from reactivex.abc import DisposableBase
|
|
5
4
|
|
|
@@ -13,7 +12,7 @@ class RefCountDisposable(DisposableBase):
|
|
|
13
12
|
|
|
14
13
|
class InnerDisposable(DisposableBase):
|
|
15
14
|
def __init__(self, parent: "RefCountDisposable") -> None:
|
|
16
|
-
self.parent:
|
|
15
|
+
self.parent: RefCountDisposable | None = parent
|
|
17
16
|
self.is_disposed = False
|
|
18
17
|
self.lock = RLock()
|
|
19
18
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from reactivex import abc
|
|
5
4
|
|
|
@@ -11,13 +10,13 @@ class SerialDisposable(abc.DisposableBase):
|
|
|
11
10
|
"""
|
|
12
11
|
|
|
13
12
|
def __init__(self) -> None:
|
|
14
|
-
self.current:
|
|
13
|
+
self.current: abc.DisposableBase | None = None
|
|
15
14
|
self.is_disposed = False
|
|
16
15
|
self.lock = RLock()
|
|
17
16
|
|
|
18
17
|
super().__init__()
|
|
19
18
|
|
|
20
|
-
def get_disposable(self) ->
|
|
19
|
+
def get_disposable(self) -> abc.DisposableBase | None:
|
|
21
20
|
return self.current
|
|
22
21
|
|
|
23
22
|
def set_disposable(self, value: abc.DisposableBase) -> None:
|
|
@@ -26,7 +25,7 @@ class SerialDisposable(abc.DisposableBase):
|
|
|
26
25
|
disposable object. Assigning this property disposes the previous
|
|
27
26
|
disposable object."""
|
|
28
27
|
|
|
29
|
-
old:
|
|
28
|
+
old: abc.DisposableBase | None = None
|
|
30
29
|
|
|
31
30
|
with self.lock:
|
|
32
31
|
should_dispose = self.is_disposed
|
|
@@ -46,7 +45,7 @@ class SerialDisposable(abc.DisposableBase):
|
|
|
46
45
|
"""Disposes the underlying disposable as well as all future
|
|
47
46
|
replacements."""
|
|
48
47
|
|
|
49
|
-
old:
|
|
48
|
+
old: abc.DisposableBase | None = None
|
|
50
49
|
|
|
51
50
|
with self.lock:
|
|
52
51
|
if not self.is_disposed:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from threading import RLock
|
|
2
|
-
from typing import Optional
|
|
3
2
|
|
|
4
3
|
from reactivex.abc import DisposableBase
|
|
5
4
|
|
|
@@ -17,12 +16,12 @@ class SingleAssignmentDisposable(DisposableBase):
|
|
|
17
16
|
class.
|
|
18
17
|
"""
|
|
19
18
|
self.is_disposed: bool = False
|
|
20
|
-
self.current:
|
|
19
|
+
self.current: DisposableBase | None = None
|
|
21
20
|
self.lock = RLock()
|
|
22
21
|
|
|
23
22
|
super().__init__()
|
|
24
23
|
|
|
25
|
-
def get_disposable(self) ->
|
|
24
|
+
def get_disposable(self) -> DisposableBase | None:
|
|
26
25
|
return self.current
|
|
27
26
|
|
|
28
27
|
def set_disposable(self, value: DisposableBase) -> None:
|
|
@@ -41,7 +40,7 @@ class SingleAssignmentDisposable(DisposableBase):
|
|
|
41
40
|
|
|
42
41
|
def dispose(self) -> None:
|
|
43
42
|
"""Sets the status to disposed"""
|
|
44
|
-
old:
|
|
43
|
+
old: DisposableBase | None = None
|
|
45
44
|
|
|
46
45
|
with self.lock:
|
|
47
46
|
if not self.is_disposed:
|
reactivex/internal/__init__.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .basic import default_comparer, default_error, noop
|
|
2
2
|
from .concurrency import default_thread_factory, synchronized
|
|
3
3
|
from .constants import DELTA_ZERO, UTC_ZERO
|
|
4
|
+
from .curry import curry_flip
|
|
4
5
|
from .exceptions import (
|
|
5
6
|
ArgumentOutOfRangeException,
|
|
6
7
|
DisposedException,
|
|
@@ -13,6 +14,7 @@ __all__ = [
|
|
|
13
14
|
"add_ref",
|
|
14
15
|
"alias",
|
|
15
16
|
"ArgumentOutOfRangeException",
|
|
17
|
+
"curry_flip",
|
|
16
18
|
"DisposedException",
|
|
17
19
|
"default_comparer",
|
|
18
20
|
"default_error",
|
reactivex/internal/basic.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from datetime import datetime, timezone
|
|
2
|
-
from typing import Any, NoReturn, TypeVar
|
|
2
|
+
from typing import Any, NoReturn, TypeVar
|
|
3
3
|
|
|
4
4
|
_T = TypeVar("_T")
|
|
5
5
|
|
|
@@ -29,7 +29,7 @@ def default_key_serializer(x: Any) -> str:
|
|
|
29
29
|
return str(x)
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def default_error(err:
|
|
32
|
+
def default_error(err: Exception | str) -> NoReturn:
|
|
33
33
|
if isinstance(err, BaseException):
|
|
34
34
|
raise err
|
|
35
35
|
|