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.
Files changed (219) hide show
  1. reactivex/__init__.py +35 -39
  2. reactivex/_version.py +1 -1
  3. reactivex/abc/disposable.py +3 -4
  4. reactivex/abc/observable.py +13 -6
  5. reactivex/abc/observer.py +2 -1
  6. reactivex/abc/periodicscheduler.py +7 -6
  7. reactivex/abc/scheduler.py +10 -9
  8. reactivex/abc/subject.py +5 -5
  9. reactivex/disposable/compositedisposable.py +4 -4
  10. reactivex/disposable/disposable.py +1 -2
  11. reactivex/disposable/multipleassignmentdisposable.py +2 -3
  12. reactivex/disposable/refcountdisposable.py +1 -2
  13. reactivex/disposable/serialdisposable.py +4 -5
  14. reactivex/disposable/singleassignmentdisposable.py +3 -4
  15. reactivex/internal/__init__.py +2 -0
  16. reactivex/internal/basic.py +2 -2
  17. reactivex/internal/concurrency.py +2 -1
  18. reactivex/internal/curry.py +59 -0
  19. reactivex/internal/exceptions.py +7 -12
  20. reactivex/internal/priorityqueue.py +2 -2
  21. reactivex/internal/utils.py +3 -2
  22. reactivex/notification.py +22 -21
  23. reactivex/observable/case.py +5 -6
  24. reactivex/observable/catch.py +3 -2
  25. reactivex/observable/combinelatest.py +4 -5
  26. reactivex/observable/concat.py +3 -2
  27. reactivex/observable/connectableobservable.py +7 -7
  28. reactivex/observable/defer.py +4 -3
  29. reactivex/observable/empty.py +3 -4
  30. reactivex/observable/forkjoin.py +5 -5
  31. reactivex/observable/fromcallback.py +4 -3
  32. reactivex/observable/fromfuture.py +2 -2
  33. reactivex/observable/fromiterable.py +4 -3
  34. reactivex/observable/generate.py +2 -2
  35. reactivex/observable/generatewithrelativetime.py +4 -3
  36. reactivex/observable/groupedobservable.py +4 -4
  37. reactivex/observable/ifthen.py +3 -2
  38. reactivex/observable/interval.py +1 -4
  39. reactivex/observable/marbles.py +18 -17
  40. reactivex/observable/mixins/__init__.py +32 -0
  41. reactivex/observable/mixins/combination.py +481 -0
  42. reactivex/observable/mixins/conditional.py +135 -0
  43. reactivex/observable/mixins/error_handling.py +130 -0
  44. reactivex/observable/mixins/filtering.py +1119 -0
  45. reactivex/observable/mixins/mathematical.py +277 -0
  46. reactivex/observable/mixins/multicasting.py +306 -0
  47. reactivex/observable/mixins/testing.py +193 -0
  48. reactivex/observable/mixins/time_based.py +209 -0
  49. reactivex/observable/mixins/transformation.py +632 -0
  50. reactivex/observable/mixins/utility.py +811 -0
  51. reactivex/observable/mixins/windowing.py +688 -0
  52. reactivex/observable/never.py +2 -2
  53. reactivex/observable/observable.py +72 -25
  54. reactivex/observable/onerrorresumenext.py +7 -6
  55. reactivex/observable/range.py +6 -6
  56. reactivex/observable/repeat.py +2 -2
  57. reactivex/observable/returnvalue.py +6 -5
  58. reactivex/observable/start.py +3 -2
  59. reactivex/observable/startasync.py +2 -1
  60. reactivex/observable/throw.py +3 -3
  61. reactivex/observable/timer.py +12 -12
  62. reactivex/observable/toasync.py +3 -2
  63. reactivex/observable/using.py +5 -4
  64. reactivex/observable/withlatestfrom.py +4 -5
  65. reactivex/observable/zip.py +7 -6
  66. reactivex/observer/autodetachobserver.py +4 -4
  67. reactivex/observer/observer.py +5 -4
  68. reactivex/observer/scheduledobserver.py +2 -2
  69. reactivex/operators/__init__.py +162 -208
  70. reactivex/operators/_all.py +23 -6
  71. reactivex/operators/_amb.py +88 -75
  72. reactivex/operators/_asobservable.py +20 -17
  73. reactivex/operators/_average.py +48 -45
  74. reactivex/operators/_buffer.py +81 -35
  75. reactivex/operators/_bufferwithtime.py +29 -9
  76. reactivex/operators/_bufferwithtimeorcount.py +27 -8
  77. reactivex/operators/_catch.py +33 -32
  78. reactivex/operators/_combinelatest.py +28 -20
  79. reactivex/operators/_concat.py +16 -13
  80. reactivex/operators/_contains.py +25 -6
  81. reactivex/operators/_count.py +24 -8
  82. reactivex/operators/_debounce.py +141 -138
  83. reactivex/operators/_defaultifempty.py +45 -42
  84. reactivex/operators/_delay.py +24 -23
  85. reactivex/operators/_delaysubscription.py +23 -21
  86. reactivex/operators/_delaywithmapper.py +10 -11
  87. reactivex/operators/_dematerialize.py +25 -21
  88. reactivex/operators/_distinct.py +50 -46
  89. reactivex/operators/_distinctuntilchanged.py +60 -57
  90. reactivex/operators/_do.py +123 -116
  91. reactivex/operators/_dowhile.py +3 -2
  92. reactivex/operators/_elementatordefault.py +57 -33
  93. reactivex/operators/_exclusive.py +59 -53
  94. reactivex/operators/_expand.py +82 -77
  95. reactivex/operators/_filter.py +63 -68
  96. reactivex/operators/_finallyaction.py +3 -2
  97. reactivex/operators/_find.py +49 -32
  98. reactivex/operators/_first.py +18 -11
  99. reactivex/operators/_firstordefault.py +5 -4
  100. reactivex/operators/_flatmap.py +89 -83
  101. reactivex/operators/_forkjoin.py +23 -18
  102. reactivex/operators/_groupby.py +27 -6
  103. reactivex/operators/_groupbyuntil.py +8 -5
  104. reactivex/operators/_groupjoin.py +7 -6
  105. reactivex/operators/_ignoreelements.py +20 -15
  106. reactivex/operators/_isempty.py +15 -4
  107. reactivex/operators/_join.py +6 -5
  108. reactivex/operators/_last.py +36 -31
  109. reactivex/operators/_lastordefault.py +8 -8
  110. reactivex/operators/_map.py +54 -39
  111. reactivex/operators/_materialize.py +30 -31
  112. reactivex/operators/_max.py +18 -11
  113. reactivex/operators/_maxby.py +5 -5
  114. reactivex/operators/_merge.py +132 -129
  115. reactivex/operators/_min.py +16 -10
  116. reactivex/operators/_minby.py +9 -8
  117. reactivex/operators/_multicast.py +9 -9
  118. reactivex/operators/_observeon.py +35 -31
  119. reactivex/operators/_onerrorresumenext.py +2 -1
  120. reactivex/operators/_pairwise.py +38 -34
  121. reactivex/operators/_partition.py +80 -73
  122. reactivex/operators/_pluck.py +4 -3
  123. reactivex/operators/_publish.py +36 -21
  124. reactivex/operators/_publishvalue.py +8 -7
  125. reactivex/operators/_reduce.py +16 -12
  126. reactivex/operators/_repeat.py +33 -30
  127. reactivex/operators/_replay.py +9 -9
  128. reactivex/operators/_retry.py +12 -10
  129. reactivex/operators/_sample.py +31 -27
  130. reactivex/operators/_scan.py +41 -39
  131. reactivex/operators/_sequenceequal.py +8 -7
  132. reactivex/operators/_single.py +20 -13
  133. reactivex/operators/_singleordefault.py +6 -5
  134. reactivex/operators/_skip.py +35 -32
  135. reactivex/operators/_skiplast.py +38 -34
  136. reactivex/operators/_skiplastwithtime.py +5 -4
  137. reactivex/operators/_skipuntil.py +40 -35
  138. reactivex/operators/_skipuntilwithtime.py +4 -3
  139. reactivex/operators/_skipwhile.py +65 -44
  140. reactivex/operators/_skipwithtime.py +50 -46
  141. reactivex/operators/_slice.py +58 -53
  142. reactivex/operators/_some.py +48 -47
  143. reactivex/operators/_startswith.py +17 -15
  144. reactivex/operators/_subscribeon.py +44 -41
  145. reactivex/operators/_sum.py +23 -6
  146. reactivex/operators/_switchlatest.py +71 -69
  147. reactivex/operators/_take.py +37 -33
  148. reactivex/operators/_takelast.py +37 -36
  149. reactivex/operators/_takelastbuffer.py +38 -37
  150. reactivex/operators/_takelastwithtime.py +60 -56
  151. reactivex/operators/_takeuntil.py +33 -32
  152. reactivex/operators/_takeuntilwithtime.py +42 -39
  153. reactivex/operators/_takewhile.py +108 -100
  154. reactivex/operators/_takewithtime.py +46 -41
  155. reactivex/operators/_throttlefirst.py +52 -45
  156. reactivex/operators/_timeinterval.py +40 -36
  157. reactivex/operators/_timeout.py +81 -79
  158. reactivex/operators/_timeoutwithmapper.py +6 -5
  159. reactivex/operators/_timestamp.py +24 -22
  160. reactivex/operators/_todict.py +51 -43
  161. reactivex/operators/_tofuture.py +24 -15
  162. reactivex/operators/_toiterable.py +33 -27
  163. reactivex/operators/_tomarbles.py +5 -5
  164. reactivex/operators/_toset.py +29 -19
  165. reactivex/operators/_whiledo.py +2 -1
  166. reactivex/operators/_window.py +100 -99
  167. reactivex/operators/_windowwithcount.py +56 -54
  168. reactivex/operators/_windowwithtime.py +95 -79
  169. reactivex/operators/_windowwithtimeorcount.py +85 -69
  170. reactivex/operators/_withlatestfrom.py +13 -9
  171. reactivex/operators/_zip.py +67 -63
  172. reactivex/operators/connectable/_refcount.py +4 -3
  173. reactivex/pipe.py +2 -1
  174. reactivex/run.py +8 -4
  175. reactivex/scheduler/catchscheduler.py +11 -10
  176. reactivex/scheduler/currentthreadscheduler.py +2 -3
  177. reactivex/scheduler/eventloop/asyncioscheduler.py +7 -6
  178. reactivex/scheduler/eventloop/asynciothreadsafescheduler.py +12 -14
  179. reactivex/scheduler/eventloop/eventletscheduler.py +4 -4
  180. reactivex/scheduler/eventloop/geventscheduler.py +4 -4
  181. reactivex/scheduler/eventloop/ioloopscheduler.py +4 -4
  182. reactivex/scheduler/eventloop/twistedscheduler.py +4 -4
  183. reactivex/scheduler/eventloopscheduler.py +9 -12
  184. reactivex/scheduler/historicalscheduler.py +1 -2
  185. reactivex/scheduler/immediatescheduler.py +5 -4
  186. reactivex/scheduler/mainloop/gtkscheduler.py +6 -7
  187. reactivex/scheduler/mainloop/pygamescheduler.py +4 -4
  188. reactivex/scheduler/mainloop/qtscheduler.py +6 -6
  189. reactivex/scheduler/mainloop/tkinterscheduler.py +4 -4
  190. reactivex/scheduler/mainloop/wxscheduler.py +7 -7
  191. reactivex/scheduler/newthreadscheduler.py +6 -8
  192. reactivex/scheduler/periodicscheduler.py +4 -4
  193. reactivex/scheduler/scheduleditem.py +4 -4
  194. reactivex/scheduler/scheduler.py +5 -5
  195. reactivex/scheduler/threadpoolscheduler.py +3 -3
  196. reactivex/scheduler/timeoutscheduler.py +5 -4
  197. reactivex/scheduler/trampoline.py +1 -2
  198. reactivex/scheduler/trampolinescheduler.py +5 -6
  199. reactivex/scheduler/virtualtimescheduler.py +4 -4
  200. reactivex/subject/asyncsubject.py +2 -2
  201. reactivex/subject/behaviorsubject.py +2 -2
  202. reactivex/subject/innersubscription.py +2 -2
  203. reactivex/subject/replaysubject.py +8 -8
  204. reactivex/subject/subject.py +4 -4
  205. reactivex/testing/coldobservable.py +5 -5
  206. reactivex/testing/hotobservable.py +6 -6
  207. reactivex/testing/marbles.py +21 -20
  208. reactivex/testing/mockdisposable.py +1 -3
  209. reactivex/testing/mockobserver.py +2 -2
  210. reactivex/testing/reactivetest.py +2 -2
  211. reactivex/testing/recorded.py +1 -1
  212. reactivex/testing/subscription.py +3 -3
  213. reactivex/testing/testscheduler.py +13 -12
  214. reactivex/typing.py +25 -14
  215. {reactivex-4.1.0.dist-info → reactivex-5.0.0a2.dist-info}/METADATA +59 -26
  216. reactivex-5.0.0a2.dist-info/RECORD +236 -0
  217. {reactivex-4.1.0.dist-info → reactivex-5.0.0a2.dist-info}/WHEEL +1 -1
  218. reactivex-4.1.0.dist-info/RECORD +0 -223
  219. {reactivex-4.1.0.dist-info → reactivex-5.0.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import threading
3
3
  from collections import deque
4
- from typing import Deque, Optional, TypeVar
4
+ from typing import TypeVar
5
5
 
6
6
  from reactivex import abc, typing
7
7
  from reactivex.disposable import Disposable
@@ -23,7 +23,7 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
23
23
 
24
24
  def __init__(
25
25
  self,
26
- thread_factory: Optional[typing.StartableFactory] = None,
26
+ thread_factory: typing.StartableFactory | None = None,
27
27
  exit_if_empty: bool = False,
28
28
  ) -> None:
29
29
  super().__init__()
@@ -32,15 +32,15 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
32
32
  self._thread_factory: typing.StartableFactory = (
33
33
  thread_factory or default_thread_factory
34
34
  )
35
- self._thread: Optional[typing.Startable] = None
35
+ self._thread: typing.Startable | None = None
36
36
  self._condition = threading.Condition(threading.Lock())
37
37
  self._queue: PriorityQueue[ScheduledItem] = PriorityQueue()
38
- self._ready_list: Deque[ScheduledItem] = deque()
38
+ self._ready_list: deque[ScheduledItem] = deque()
39
39
 
40
40
  self._exit_if_empty = exit_if_empty
41
41
 
42
42
  def schedule(
43
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
43
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
44
44
  ) -> abc.DisposableBase:
45
45
  """Schedules an action to be executed.
46
46
 
@@ -59,7 +59,7 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
59
59
  self,
60
60
  duetime: typing.RelativeTime,
61
61
  action: typing.ScheduledAction[_TState],
62
- state: Optional[_TState] = None,
62
+ state: _TState | None = None,
63
63
  ) -> abc.DisposableBase:
64
64
  """Schedules an action to be executed after duetime.
65
65
 
@@ -80,7 +80,7 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
80
80
  self,
81
81
  duetime: typing.AbsoluteTime,
82
82
  action: typing.ScheduledAction[_TState],
83
- state: Optional[_TState] = None,
83
+ state: _TState | None = None,
84
84
  ) -> abc.DisposableBase:
85
85
  """Schedules an action to be executed at duetime.
86
86
 
@@ -114,7 +114,7 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
114
114
  self,
115
115
  period: typing.RelativeTime,
116
116
  action: typing.ScheduledPeriodicAction[_TState],
117
- state: Optional[_TState] = None,
117
+ state: _TState | None = None,
118
118
  ) -> abc.DisposableBase:
119
119
  """Schedules a periodic piece of work.
120
120
 
@@ -154,12 +154,10 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
154
154
  The loop is suspended/resumed using the condition which gets notified
155
155
  by calls to Schedule or calls to dispose."""
156
156
 
157
- ready: Deque[ScheduledItem] = deque()
157
+ ready: deque[ScheduledItem] = deque()
158
158
 
159
159
  while True:
160
-
161
160
  with self._condition:
162
-
163
161
  # The notification could be because of a call to dispose. This
164
162
  # takes precedence over everything else: We'll exit the loop
165
163
  # immediately. Subsequent calls to Schedule won't ever create a
@@ -188,7 +186,6 @@ class EventLoopScheduler(PeriodicScheduler, abc.DisposableBase):
188
186
 
189
187
  # Wait for next cycle, or if we're done let's exit if so configured
190
188
  with self._condition:
191
-
192
189
  if self._ready_list:
193
190
  continue
194
191
 
@@ -1,5 +1,4 @@
1
1
  from datetime import datetime
2
- from typing import Optional
3
2
 
4
3
  from .scheduler import UTC_ZERO
5
4
  from .virtualtimescheduler import VirtualTimeScheduler
@@ -9,7 +8,7 @@ class HistoricalScheduler(VirtualTimeScheduler):
9
8
  """Provides a virtual time scheduler that uses datetime for absolute time
10
9
  and timedelta for relative time."""
11
10
 
12
- def __init__(self, initial_clock: Optional[datetime] = None) -> None:
11
+ def __init__(self, initial_clock: datetime | None = None) -> None:
13
12
  """Creates a new historical scheduler with the specified initial clock
14
13
  value.
15
14
 
@@ -1,5 +1,6 @@
1
+ from collections.abc import MutableMapping
1
2
  from threading import Lock
2
- from typing import MutableMapping, Optional, TypeVar
3
+ from typing import TypeVar
3
4
  from weakref import WeakKeyDictionary
4
5
 
5
6
  from reactivex import abc, typing
@@ -35,7 +36,7 @@ class ImmediateScheduler(Scheduler):
35
36
  return cls.singleton()
36
37
 
37
38
  def schedule(
38
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
39
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
39
40
  ) -> abc.DisposableBase:
40
41
  """Schedules an action to be executed.
41
42
 
@@ -54,7 +55,7 @@ class ImmediateScheduler(Scheduler):
54
55
  self,
55
56
  duetime: typing.RelativeTime,
56
57
  action: typing.ScheduledAction[_TState],
57
- state: Optional[_TState] = None,
58
+ state: _TState | None = None,
58
59
  ) -> abc.DisposableBase:
59
60
  """Schedules an action to be executed after duetime.
60
61
 
@@ -78,7 +79,7 @@ class ImmediateScheduler(Scheduler):
78
79
  self,
79
80
  duetime: typing.AbsoluteTime,
80
81
  action: typing.ScheduledAction[_TState],
81
- state: Optional[_TState] = None,
82
+ state: _TState | None = None,
82
83
  ) -> abc.DisposableBase:
83
84
  """Schedules an action to be executed at duetime.
84
85
 
@@ -1,4 +1,4 @@
1
- from typing import Any, Optional, TypeVar, cast
1
+ from typing import Any, TypeVar, cast
2
2
 
3
3
  from reactivex import abc, typing
4
4
  from reactivex.disposable import (
@@ -36,10 +36,9 @@ class GtkScheduler(PeriodicScheduler):
36
36
  self,
37
37
  time: typing.AbsoluteOrRelativeTime,
38
38
  action: typing.ScheduledSingleOrPeriodicAction[_TState],
39
- state: Optional[_TState] = None,
39
+ state: _TState | None = None,
40
40
  periodic: bool = False,
41
41
  ) -> abc.DisposableBase:
42
-
43
42
  msecs = max(0, int(self.to_seconds(time) * 1000.0))
44
43
 
45
44
  sad = SingleAssignmentDisposable()
@@ -69,7 +68,7 @@ class GtkScheduler(PeriodicScheduler):
69
68
  return CompositeDisposable(sad, Disposable(dispose))
70
69
 
71
70
  def schedule(
72
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
71
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
73
72
  ) -> abc.DisposableBase:
74
73
  """Schedules an action to be executed.
75
74
 
@@ -87,7 +86,7 @@ class GtkScheduler(PeriodicScheduler):
87
86
  self,
88
87
  duetime: typing.RelativeTime,
89
88
  action: typing.ScheduledAction[_TState],
90
- state: Optional[_TState] = None,
89
+ state: _TState | None = None,
91
90
  ) -> abc.DisposableBase:
92
91
  """Schedules an action to be executed after duetime.
93
92
 
@@ -106,7 +105,7 @@ class GtkScheduler(PeriodicScheduler):
106
105
  self,
107
106
  duetime: typing.AbsoluteTime,
108
107
  action: typing.ScheduledAction[_TState],
109
- state: Optional[_TState] = None,
108
+ state: _TState | None = None,
110
109
  ) -> abc.DisposableBase:
111
110
  """Schedules an action to be executed at duetime.
112
111
 
@@ -127,7 +126,7 @@ class GtkScheduler(PeriodicScheduler):
127
126
  self,
128
127
  period: typing.RelativeTime,
129
128
  action: typing.ScheduledPeriodicAction[_TState],
130
- state: Optional[_TState] = None,
129
+ state: _TState | None = None,
131
130
  ) -> abc.DisposableBase:
132
131
  """Schedules a periodic piece of work to be executed in the loop.
133
132
 
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  import threading
3
- from typing import Any, Optional, TypeVar
3
+ from typing import Any, TypeVar
4
4
 
5
5
  from reactivex import abc, typing
6
6
  from reactivex.internal import PriorityQueue
@@ -36,7 +36,7 @@ class PyGameScheduler(PeriodicScheduler):
36
36
  self._queue: PriorityQueue[ScheduledItem] = PriorityQueue()
37
37
 
38
38
  def schedule(
39
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
39
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
40
40
  ) -> abc.DisposableBase:
41
41
  """Schedules an action to be executed.
42
42
 
@@ -56,7 +56,7 @@ class PyGameScheduler(PeriodicScheduler):
56
56
  self,
57
57
  duetime: typing.RelativeTime,
58
58
  action: typing.ScheduledAction[_TState],
59
- state: Optional[_TState] = None,
59
+ state: _TState | None = None,
60
60
  ) -> abc.DisposableBase:
61
61
  """Schedules an action to be executed after duetime.
62
62
  Args:
@@ -76,7 +76,7 @@ class PyGameScheduler(PeriodicScheduler):
76
76
  self,
77
77
  duetime: typing.AbsoluteTime,
78
78
  action: typing.ScheduledAction[_TState],
79
- state: Optional[_TState] = None,
79
+ state: _TState | None = None,
80
80
  ) -> abc.DisposableBase:
81
81
  """Schedules an action to be executed at duetime.
82
82
 
@@ -1,6 +1,6 @@
1
1
  import logging
2
2
  from datetime import timedelta
3
- from typing import Any, Optional, Set, TypeVar
3
+ from typing import Any, TypeVar
4
4
 
5
5
  from reactivex import abc, typing
6
6
  from reactivex.disposable import (
@@ -28,10 +28,10 @@ class QtScheduler(PeriodicScheduler):
28
28
  """
29
29
  super().__init__()
30
30
  self._qtcore = qtcore
31
- self._periodic_timers: Set[Any] = set()
31
+ self._periodic_timers: set[Any] = set()
32
32
 
33
33
  def schedule(
34
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
34
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
35
35
  ) -> abc.DisposableBase:
36
36
  """Schedules an action to be executed.
37
37
 
@@ -49,7 +49,7 @@ class QtScheduler(PeriodicScheduler):
49
49
  self,
50
50
  duetime: typing.RelativeTime,
51
51
  action: typing.ScheduledAction[_TState],
52
- state: Optional[_TState] = None,
52
+ state: _TState | None = None,
53
53
  ) -> abc.DisposableBase:
54
54
  """Schedules an action to be executed after duetime.
55
55
 
@@ -85,7 +85,7 @@ class QtScheduler(PeriodicScheduler):
85
85
  self,
86
86
  duetime: typing.AbsoluteTime,
87
87
  action: typing.ScheduledAction[_TState],
88
- state: Optional[_TState] = None,
88
+ state: _TState | None = None,
89
89
  ) -> abc.DisposableBase:
90
90
  """Schedules an action to be executed at duetime.
91
91
 
@@ -106,7 +106,7 @@ class QtScheduler(PeriodicScheduler):
106
106
  self,
107
107
  period: typing.RelativeTime,
108
108
  action: typing.ScheduledPeriodicAction[_TState],
109
- state: Optional[_TState] = None,
109
+ state: _TState | None = None,
110
110
  ) -> abc.DisposableBase:
111
111
  """Schedules a periodic piece of work to be executed in the loop.
112
112
 
@@ -1,4 +1,4 @@
1
- from typing import Any, Optional, TypeVar
1
+ from typing import Any, TypeVar
2
2
 
3
3
  from reactivex import abc, typing
4
4
  from reactivex.disposable import (
@@ -30,7 +30,7 @@ class TkinterScheduler(PeriodicScheduler):
30
30
  self._root = root
31
31
 
32
32
  def schedule(
33
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
33
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
34
34
  ) -> abc.DisposableBase:
35
35
  """Schedules an action to be executed.
36
36
 
@@ -49,7 +49,7 @@ class TkinterScheduler(PeriodicScheduler):
49
49
  self,
50
50
  duetime: typing.RelativeTime,
51
51
  action: typing.ScheduledAction[_TState],
52
- state: Optional[_TState] = None,
52
+ state: _TState | None = None,
53
53
  ) -> abc.DisposableBase:
54
54
  """Schedules an action to be executed after duetime.
55
55
 
@@ -80,7 +80,7 @@ class TkinterScheduler(PeriodicScheduler):
80
80
  self,
81
81
  duetime: typing.AbsoluteTime,
82
82
  action: typing.ScheduledAction[_TState],
83
- state: Optional[_TState] = None,
83
+ state: _TState | None = None,
84
84
  ) -> abc.DisposableBase:
85
85
  """Schedules an action to be executed at duetime.
86
86
 
@@ -1,5 +1,5 @@
1
1
  import logging
2
- from typing import Any, Optional, Set, TypeVar, cast
2
+ from typing import Any, TypeVar, cast
3
3
 
4
4
  from reactivex import abc, typing
5
5
  from reactivex.disposable import (
@@ -39,7 +39,7 @@ class WxScheduler(PeriodicScheduler):
39
39
  self.callback()
40
40
 
41
41
  self._timer_class = Timer
42
- self._timers: Set[Timer] = set()
42
+ self._timers: set[Timer] = set()
43
43
 
44
44
  def cancel_all(self) -> None:
45
45
  """Cancel all scheduled actions.
@@ -54,7 +54,7 @@ class WxScheduler(PeriodicScheduler):
54
54
  self,
55
55
  time: typing.AbsoluteOrRelativeTime,
56
56
  action: typing.ScheduledSingleOrPeriodicAction[_TState],
57
- state: Optional[_TState] = None,
57
+ state: _TState | None = None,
58
58
  periodic: bool = False,
59
59
  ) -> abc.DisposableBase:
60
60
  scheduler = self
@@ -89,7 +89,7 @@ class WxScheduler(PeriodicScheduler):
89
89
  return CompositeDisposable(sad, Disposable(dispose))
90
90
 
91
91
  def schedule(
92
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
92
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
93
93
  ) -> abc.DisposableBase:
94
94
  """Schedules an action to be executed.
95
95
 
@@ -120,7 +120,7 @@ class WxScheduler(PeriodicScheduler):
120
120
  self,
121
121
  duetime: typing.RelativeTime,
122
122
  action: typing.ScheduledAction[_TState],
123
- state: Optional[_TState] = None,
123
+ state: _TState | None = None,
124
124
  ) -> abc.DisposableBase:
125
125
  """Schedules an action to be executed after duetime.
126
126
 
@@ -139,7 +139,7 @@ class WxScheduler(PeriodicScheduler):
139
139
  self,
140
140
  duetime: typing.AbsoluteTime,
141
141
  action: typing.ScheduledAction[_TState],
142
- state: Optional[_TState] = None,
142
+ state: _TState | None = None,
143
143
  ) -> abc.DisposableBase:
144
144
  """Schedules an action to be executed at duetime.
145
145
 
@@ -160,7 +160,7 @@ class WxScheduler(PeriodicScheduler):
160
160
  self,
161
161
  period: typing.RelativeTime,
162
162
  action: typing.ScheduledPeriodicAction[_TState],
163
- state: Optional[_TState] = None,
163
+ state: _TState | None = None,
164
164
  ) -> abc.DisposableBase:
165
165
  """Schedules a periodic piece of work to be executed in the loop.
166
166
 
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import threading
3
3
  from datetime import datetime
4
- from typing import Optional, TypeVar
4
+ from typing import TypeVar
5
5
 
6
6
  from reactivex import abc, typing
7
7
  from reactivex.disposable import Disposable
@@ -18,16 +18,14 @@ log = logging.getLogger("Rx")
18
18
  class NewThreadScheduler(PeriodicScheduler):
19
19
  """Creates an object that schedules each unit of work on a separate thread."""
20
20
 
21
- def __init__(
22
- self, thread_factory: Optional[typing.StartableFactory] = None
23
- ) -> None:
21
+ def __init__(self, thread_factory: typing.StartableFactory | None = None) -> None:
24
22
  super().__init__()
25
23
  self.thread_factory: typing.StartableFactory = (
26
24
  thread_factory or default_thread_factory
27
25
  )
28
26
 
29
27
  def schedule(
30
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
28
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
31
29
  ) -> abc.DisposableBase:
32
30
  """Schedules an action to be executed.
33
31
 
@@ -49,7 +47,7 @@ class NewThreadScheduler(PeriodicScheduler):
49
47
  self,
50
48
  duetime: typing.RelativeTime,
51
49
  action: typing.ScheduledAction[_TState],
52
- state: Optional[_TState] = None,
50
+ state: _TState | None = None,
53
51
  ) -> abc.DisposableBase:
54
52
  """Schedules an action to be executed after duetime.
55
53
 
@@ -72,7 +70,7 @@ class NewThreadScheduler(PeriodicScheduler):
72
70
  self,
73
71
  duetime: typing.AbsoluteTime,
74
72
  action: typing.ScheduledAction[_TState],
75
- state: Optional[_TState] = None,
73
+ state: _TState | None = None,
76
74
  ) -> abc.DisposableBase:
77
75
  """Schedules an action to be executed at duetime.
78
76
 
@@ -93,7 +91,7 @@ class NewThreadScheduler(PeriodicScheduler):
93
91
  self,
94
92
  period: typing.RelativeTime,
95
93
  action: typing.ScheduledPeriodicAction[_TState],
96
- state: Optional[_TState] = None,
94
+ state: _TState | None = None,
97
95
  ) -> abc.DisposableBase:
98
96
  """Schedules a periodic piece of work.
99
97
 
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Optional, TypeVar
2
+ from typing import TypeVar
3
3
 
4
4
  from reactivex import abc, typing
5
5
  from reactivex.disposable import Disposable, MultipleAssignmentDisposable
@@ -18,7 +18,7 @@ class PeriodicScheduler(Scheduler, abc.PeriodicSchedulerBase):
18
18
  self,
19
19
  period: typing.RelativeTime,
20
20
  action: typing.ScheduledPeriodicAction[_TState],
21
- state: Optional[_TState] = None,
21
+ state: _TState | None = None,
22
22
  ) -> abc.DisposableBase:
23
23
  """Schedules a periodic piece of work.
24
24
 
@@ -38,8 +38,8 @@ class PeriodicScheduler(Scheduler, abc.PeriodicSchedulerBase):
38
38
  seconds: float = self.to_seconds(period)
39
39
 
40
40
  def periodic(
41
- scheduler: abc.SchedulerBase, state: Optional[_TState] = None
42
- ) -> Optional[Disposable]:
41
+ scheduler: abc.SchedulerBase, state: _TState | None = None
42
+ ) -> Disposable | None:
43
43
  if disp.is_disposed:
44
44
  return None
45
45
 
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Any, Optional
2
+ from typing import Any
3
3
 
4
4
  from reactivex import abc
5
5
  from reactivex.disposable import SingleAssignmentDisposable
@@ -7,16 +7,16 @@ from reactivex.disposable import SingleAssignmentDisposable
7
7
  from .scheduler import Scheduler
8
8
 
9
9
 
10
- class ScheduledItem(object):
10
+ class ScheduledItem:
11
11
  def __init__(
12
12
  self,
13
13
  scheduler: Scheduler,
14
- state: Optional[Any],
14
+ state: Any | None,
15
15
  action: abc.ScheduledAction[Any],
16
16
  duetime: datetime,
17
17
  ) -> None:
18
18
  self.scheduler: Scheduler = scheduler
19
- self.state: Optional[Any] = state
19
+ self.state: Any | None = state
20
20
  self.action: abc.ScheduledAction[Any] = action
21
21
  self.duetime: datetime = duetime
22
22
  self.disposable: SingleAssignmentDisposable = SingleAssignmentDisposable()
@@ -1,6 +1,6 @@
1
1
  from abc import abstractmethod
2
2
  from datetime import datetime, timedelta, timezone
3
- from typing import Optional, TypeVar
3
+ from typing import TypeVar
4
4
 
5
5
  from reactivex import abc, typing
6
6
  from reactivex.disposable import Disposable
@@ -30,7 +30,7 @@ class Scheduler(abc.SchedulerBase):
30
30
 
31
31
  @abstractmethod
32
32
  def schedule(
33
- self, action: abc.ScheduledAction[_TState], state: Optional[_TState] = None
33
+ self, action: abc.ScheduledAction[_TState], state: _TState | None = None
34
34
  ) -> abc.DisposableBase:
35
35
  """Schedules an action to be executed.
36
36
 
@@ -50,7 +50,7 @@ class Scheduler(abc.SchedulerBase):
50
50
  self,
51
51
  duetime: typing.RelativeTime,
52
52
  action: abc.ScheduledAction[_TState],
53
- state: Optional[_TState] = None,
53
+ state: _TState | None = None,
54
54
  ) -> abc.DisposableBase:
55
55
  """Schedules an action to be executed after duetime.
56
56
 
@@ -71,7 +71,7 @@ class Scheduler(abc.SchedulerBase):
71
71
  self,
72
72
  duetime: typing.AbsoluteTime,
73
73
  action: abc.ScheduledAction[_TState],
74
- state: Optional[_TState] = None,
74
+ state: _TState | None = None,
75
75
  ) -> abc.DisposableBase:
76
76
  """Schedules an action to be executed at duetime.
77
77
 
@@ -88,7 +88,7 @@ class Scheduler(abc.SchedulerBase):
88
88
  return NotImplemented
89
89
 
90
90
  def invoke_action(
91
- self, action: abc.ScheduledAction[_TState], state: Optional[_TState] = None
91
+ self, action: abc.ScheduledAction[_TState], state: _TState | None = None
92
92
  ) -> abc.DisposableBase:
93
93
  """Invoke the given given action. This is typically called by instances
94
94
  of ScheduledItem.
@@ -1,5 +1,5 @@
1
1
  from concurrent.futures import Future, ThreadPoolExecutor
2
- from typing import Any, Optional
2
+ from typing import Any
3
3
 
4
4
  from reactivex import abc, typing
5
5
 
@@ -17,7 +17,7 @@ class ThreadPoolScheduler(NewThreadScheduler):
17
17
  ):
18
18
  self.executor: ThreadPoolExecutor = executor
19
19
  self.target: typing.StartableTarget = target
20
- self.future: Optional["Future[Any]"] = None
20
+ self.future: Future[Any] | None = None
21
21
 
22
22
  def start(self) -> None:
23
23
  self.future = self.executor.submit(self.target)
@@ -26,7 +26,7 @@ class ThreadPoolScheduler(NewThreadScheduler):
26
26
  if self.future:
27
27
  self.future.cancel()
28
28
 
29
- def __init__(self, max_workers: Optional[int] = None) -> None:
29
+ def __init__(self, max_workers: int | None = None) -> None:
30
30
  self.executor: ThreadPoolExecutor = ThreadPoolExecutor(max_workers=max_workers)
31
31
 
32
32
  def thread_factory(
@@ -1,5 +1,6 @@
1
+ from collections.abc import MutableMapping
1
2
  from threading import Lock, Timer
2
- from typing import MutableMapping, Optional, TypeVar
3
+ from typing import TypeVar
3
4
  from weakref import WeakKeyDictionary
4
5
 
5
6
  from reactivex import abc, typing
@@ -34,7 +35,7 @@ class TimeoutScheduler(PeriodicScheduler):
34
35
  return cls.singleton()
35
36
 
36
37
  def schedule(
37
- self, action: abc.ScheduledAction[_TState], state: Optional[_TState] = None
38
+ self, action: abc.ScheduledAction[_TState], state: _TState | None = None
38
39
  ) -> abc.DisposableBase:
39
40
  """Schedules an action to be executed.
40
41
 
@@ -65,7 +66,7 @@ class TimeoutScheduler(PeriodicScheduler):
65
66
  self,
66
67
  duetime: typing.RelativeTime,
67
68
  action: abc.ScheduledAction[_TState],
68
- state: Optional[_TState] = None,
69
+ state: _TState | None = None,
69
70
  ) -> abc.DisposableBase:
70
71
  """Schedules an action to be executed after duetime.
71
72
 
@@ -101,7 +102,7 @@ class TimeoutScheduler(PeriodicScheduler):
101
102
  self,
102
103
  duetime: typing.AbsoluteTime,
103
104
  action: abc.ScheduledAction[_TState],
104
- state: Optional[_TState] = None,
105
+ state: _TState | None = None,
105
106
  ) -> abc.DisposableBase:
106
107
  """Schedules an action to be executed at duetime.
107
108
 
@@ -1,6 +1,5 @@
1
1
  from collections import deque
2
2
  from threading import Condition, Lock
3
- from typing import Deque
4
3
 
5
4
  from reactivex.internal.priorityqueue import PriorityQueue
6
5
 
@@ -34,7 +33,7 @@ class Trampoline:
34
33
  self._queue.clear()
35
34
 
36
35
  def _run(self) -> None:
37
- ready: Deque[ScheduledItem] = deque()
36
+ ready: deque[ScheduledItem] = deque()
38
37
  while True:
39
38
  with self._lock:
40
39
  while len(self._queue) > 0:
@@ -1,5 +1,5 @@
1
1
  import logging
2
- from typing import Optional, TypeVar
2
+ from typing import TypeVar
3
3
 
4
4
  from reactivex import abc, typing
5
5
  from reactivex.abc.disposable import DisposableBase
@@ -26,14 +26,13 @@ class TrampolineScheduler(Scheduler):
26
26
  """
27
27
 
28
28
  def __init__(self) -> None:
29
-
30
29
  self._tramp = Trampoline()
31
30
 
32
31
  def get_trampoline(self) -> Trampoline:
33
32
  return self._tramp
34
33
 
35
34
  def schedule(
36
- self, action: abc.ScheduledAction[_TState], state: Optional[_TState] = None
35
+ self, action: abc.ScheduledAction[_TState], state: _TState | None = None
37
36
  ) -> abc.DisposableBase:
38
37
  """Schedules an action to be executed.
39
38
 
@@ -52,7 +51,7 @@ class TrampolineScheduler(Scheduler):
52
51
  self,
53
52
  duetime: typing.RelativeTime,
54
53
  action: abc.ScheduledAction[_TState],
55
- state: Optional[_TState] = None,
54
+ state: _TState | None = None,
56
55
  ) -> abc.DisposableBase:
57
56
  """Schedules an action to be executed after duetime.
58
57
 
@@ -73,7 +72,7 @@ class TrampolineScheduler(Scheduler):
73
72
  self,
74
73
  duetime: typing.AbsoluteTime,
75
74
  action: abc.ScheduledAction[_TState],
76
- state: Optional[_TState] = None,
75
+ state: _TState | None = None,
77
76
  ) -> abc.DisposableBase:
78
77
  """Schedules an action to be executed at duetime.
79
78
 
@@ -108,7 +107,7 @@ class TrampolineScheduler(Scheduler):
108
107
 
109
108
  def ensure_trampoline(
110
109
  self, action: ScheduledAction[_TState]
111
- ) -> Optional[DisposableBase]:
110
+ ) -> DisposableBase | None:
112
111
  """Method for testing the TrampolineScheduler."""
113
112
 
114
113
  if self.schedule_required():
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
  import threading
3
3
  from datetime import datetime, timedelta
4
- from typing import Any, Optional, TypeVar
4
+ from typing import Any, TypeVar
5
5
 
6
6
  from reactivex import abc, typing
7
7
  from reactivex.abc.scheduler import AbsoluteTime
@@ -54,7 +54,7 @@ class VirtualTimeScheduler(PeriodicScheduler):
54
54
  return self.to_datetime(self._clock)
55
55
 
56
56
  def schedule(
57
- self, action: typing.ScheduledAction[_TState], state: Optional[_TState] = None
57
+ self, action: typing.ScheduledAction[_TState], state: _TState | None = None
58
58
  ) -> abc.DisposableBase:
59
59
  """Schedules an action to be executed.
60
60
 
@@ -73,7 +73,7 @@ class VirtualTimeScheduler(PeriodicScheduler):
73
73
  self,
74
74
  duetime: typing.RelativeTime,
75
75
  action: abc.ScheduledAction[_TState],
76
- state: Optional[_TState] = None,
76
+ state: _TState | None = None,
77
77
  ) -> abc.DisposableBase:
78
78
  """Schedules an action to be executed after duetime.
79
79
 
@@ -94,7 +94,7 @@ class VirtualTimeScheduler(PeriodicScheduler):
94
94
  self,
95
95
  duetime: typing.AbsoluteTime,
96
96
  action: abc.ScheduledAction[_TState],
97
- state: Optional[_TState] = None,
97
+ state: _TState | None = None,
98
98
  ) -> abc.DisposableBase:
99
99
  """Schedules an action to be executed at duetime.
100
100