Skip to content

Commit 1eaf7fe

Browse files
authored
Merge pull request #789 from LincolnPuzey/reference_docs_improvements
Small Reference docs improvements
2 parents 2c28271 + 522b7c8 commit 1eaf7fe

File tree

8 files changed

+61
-40
lines changed

8 files changed

+61
-40
lines changed

docs/source/reference.rst

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. include:: global.rst
2+
13
API Reference
24
=============
35

@@ -53,18 +55,21 @@ Brokers
5355
.. autoclass:: Broker
5456
:members:
5557
.. autoclass:: Consumer
56-
:members: __iter__, __next__, ack, nack, close
58+
:members:
5759
.. autoclass:: MessageProxy
5860
:members:
5961
.. autoclass:: dramatiq.brokers.rabbitmq.RabbitmqBroker
6062
:members:
6163
:inherited-members:
64+
:show-inheritance:
6265
.. autoclass:: dramatiq.brokers.redis.RedisBroker
6366
:members:
6467
:inherited-members:
68+
:show-inheritance:
6569
.. autoclass:: dramatiq.brokers.stub.StubBroker
6670
:members:
6771
:inherited-members:
72+
:show-inheritance:
6873

6974

7075
Middleware
@@ -129,11 +134,16 @@ The class hierarchy for middleware exceptions:
129134
+-- dramatiq.middleware.TimeLimitExceeded
130135
131136
132-
.. autoclass:: dramatiq.middleware.MiddlewareError
133-
.. autoclass:: dramatiq.middleware.SkipMessage
134-
.. autoclass:: dramatiq.middleware.Interrupt
135-
.. autoclass:: dramatiq.middleware.TimeLimitExceeded
136-
.. autoclass:: dramatiq.middleware.Shutdown
137+
.. autoexception:: dramatiq.middleware.MiddlewareError
138+
:show-inheritance:
139+
.. autoexception:: dramatiq.middleware.SkipMessage
140+
:show-inheritance:
141+
.. autoexception:: dramatiq.middleware.Interrupt
142+
:show-inheritance:
143+
.. autoexception:: dramatiq.middleware.TimeLimitExceeded
144+
:show-inheritance:
145+
.. autoexception:: dramatiq.middleware.Shutdown
146+
:show-inheritance:
137147

138148

139149
Results
@@ -149,17 +159,18 @@ Results Middleware
149159
^^^^^^^^^^^^^^^^^^
150160

151161
.. autoclass:: dramatiq.results.Results
152-
:members:
153-
:exclude-members: actor_options, after_process_message, after_skip_message, after_nack
154162

155163
Results Backends
156164
^^^^^^^^^^^^^^^^
157165

158166
.. autoclass:: dramatiq.results.ResultBackend
159167
:members:
160168
.. autoclass:: dramatiq.results.backends.MemcachedBackend
169+
:show-inheritance:
161170
.. autoclass:: dramatiq.results.backends.RedisBackend
171+
:show-inheritance:
162172
.. autoclass:: dramatiq.results.backends.StubBackend
173+
:show-inheritance:
163174

164175

165176
Rate Limiters
@@ -177,8 +188,11 @@ Rate limiter backends are used to store metadata about rate limits.
177188
.. autoclass:: dramatiq.rate_limits.RateLimiterBackend
178189
:members:
179190
.. autoclass:: dramatiq.rate_limits.backends.MemcachedBackend
191+
:show-inheritance:
180192
.. autoclass:: dramatiq.rate_limits.backends.RedisBackend
193+
:show-inheritance:
181194
.. autoclass:: dramatiq.rate_limits.backends.StubBackend
195+
:show-inheritance:
182196

183197

184198
Limiters
@@ -187,8 +201,11 @@ Limiters
187201
.. autoclass:: dramatiq.rate_limits.RateLimiter
188202
:members:
189203
.. autoclass:: dramatiq.rate_limits.BucketRateLimiter
204+
:show-inheritance:
190205
.. autoclass:: dramatiq.rate_limits.ConcurrentRateLimiter
206+
:show-inheritance:
191207
.. autoclass:: dramatiq.rate_limits.WindowRateLimiter
208+
:show-inheritance:
192209

193210
Barriers
194211
^^^^^^^^
@@ -207,34 +224,48 @@ Workers
207224
Errors
208225
------
209226

210-
.. autoclass:: DramatiqError
227+
.. autoexception:: DramatiqError
211228
:members:
212-
.. autoclass:: BrokerError
229+
:show-inheritance:
230+
.. autoexception:: BrokerError
213231
:members:
214-
.. autoclass:: DecodeError
232+
:show-inheritance:
233+
.. autoexception:: DecodeError
215234
:members:
216-
.. autoclass:: ActorNotFound
235+
:show-inheritance:
236+
.. autoexception:: ActorNotFound
217237
:members:
218-
.. autoclass:: QueueNotFound
238+
:show-inheritance:
239+
.. autoexception:: QueueNotFound
219240
:members:
220-
.. autoclass:: ConnectionError
241+
:show-inheritance:
242+
.. autoexception:: ConnectionError
221243
:members:
222-
.. autoclass:: ConnectionClosed
244+
:show-inheritance:
245+
.. autoexception:: ConnectionClosed
223246
:members:
224-
.. autoclass:: ConnectionFailed
247+
:show-inheritance:
248+
.. autoexception:: ConnectionFailed
225249
:members:
226-
.. autoclass:: RateLimitExceeded
250+
:show-inheritance:
251+
.. autoexception:: RateLimitExceeded
227252
:members:
228-
.. autoclass:: Retry
253+
:show-inheritance:
254+
.. autoexception:: Retry
229255
:members:
230-
.. autoclass:: dramatiq.results.ResultError
256+
:show-inheritance:
257+
.. autoexception:: dramatiq.results.ResultError
231258
:members:
232-
.. autoclass:: dramatiq.results.ResultMissing
259+
:show-inheritance:
260+
.. autoexception:: dramatiq.results.ResultMissing
233261
:members:
234-
.. autoclass:: dramatiq.results.ResultTimeout
262+
:show-inheritance:
263+
.. autoexception:: dramatiq.results.ResultTimeout
235264
:members:
236-
.. autoclass:: dramatiq.results.ResultFailure
265+
:show-inheritance:
266+
.. autoexception:: dramatiq.results.ResultFailure
237267
:members:
268+
:show-inheritance:
238269

239270
Environment Variables
240271
---------------------

dramatiq/actor.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
from datetime import timedelta
2222
from inspect import iscoroutinefunction
2323
from typing import (
24-
TYPE_CHECKING,
2524
Any,
2625
Awaitable,
2726
Callable,
2827
Generic,
2928
Optional,
29+
ParamSpec,
3030
TypeVar,
3131
Union,
3232
overload,
@@ -37,16 +37,11 @@
3737
from .logging import get_logger
3838
from .message import Message
3939

40-
if TYPE_CHECKING:
41-
from typing_extensions import ParamSpec
42-
43-
P = ParamSpec("P")
44-
else:
45-
P = TypeVar("P")
46-
4740
#: The regular expression that represents valid queue names.
4841
_queue_name_re = re.compile(r"[a-zA-Z_][a-zA-Z0-9._-]*")
4942

43+
# Type variables for the Actor function's parameters and return type.
44+
P = ParamSpec("P")
5045
R = TypeVar("R")
5146

5247

dramatiq/broker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Broker:
8787
to this broker. If you supply this parameter, you are
8888
expected to declare *all* middleware. Most of the time,
8989
you'll want to use :meth:`.add_middleware` instead.
90+
See :ref:`customizing-middleware` for details.
9091
9192
Attributes:
9293
actor_options(set[str]): The names of all the options actors may

dramatiq/errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class DramatiqError(Exception): # pragma: no cover
2424
"""Base class for all dramatiq errors."""
2525

26-
def __init__(self, message):
26+
def __init__(self, message): # noqa: B042
2727
self.message = message
2828

2929
def __str__(self) -> str:
@@ -33,7 +33,7 @@ def __str__(self) -> str:
3333
class DecodeError(DramatiqError):
3434
"""Raised when a message fails to decode."""
3535

36-
def __init__(self, message, data, error):
36+
def __init__(self, message, data, error): # noqa: B042
3737
super().__init__(message)
3838
self.data = data
3939
self.error = error
@@ -83,6 +83,6 @@ class Retry(DramatiqError):
8383
retried after at least that amount of time (in milliseconds).
8484
"""
8585

86-
def __init__(self, message: str = "", delay: Optional[int] = None):
86+
def __init__(self, message: str = "", delay: Optional[int] = None): # noqa: B042
8787
super().__init__(message)
8888
self.delay = delay

dramatiq/rate_limits/backends/memcached.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class MemcachedBackend(RateLimiterBackend):
3636
pool_size(int): The size of the connection pool to use.
3737
**parameters: Connection parameters are passed directly
3838
to :class:`pylibmc.Client`.
39-
40-
.. _memcached: https://memcached.org
4139
"""
4240

4341
def __init__(self, *, pool=None, pool_size=8, **parameters):

dramatiq/rate_limits/bucket.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class BucketRateLimiter(RateLimiter):
5252
key(str): The key to rate limit on.
5353
limit(int): The maximum number of operations per bucket per key.
5454
bucket(int): The bucket interval in milliseconds.
55-
56-
.. |WindowRateLimiter| replace:: :class:`WindowRateLimiter<dramatiq.rate_limits.WindowRateLimiter>`
5755
"""
5856

5957
def __init__(self, backend, key, *, limit=1, bucket=1000):

dramatiq/results/backends/memcached.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class MemcachedBackend(ResultBackend):
3535
pool_size(int): The size of the connection pool to use.
3636
**parameters: Connection parameters are passed directly
3737
to :class:`pylibmc.Client`.
38-
39-
.. _memcached: https://memcached.org
4038
"""
4139

4240
def __init__(self, *, namespace="dramatiq-results", encoder=None, pool=None, pool_size=8, **parameters):

dramatiq/results/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ResultMissing(ResultError):
3535
class ResultFailure(ResultError):
3636
"""Raised when getting a result from an actor that failed."""
3737

38-
def __init__(self, message="", orig_exc_type="", orig_exc_msg=""):
38+
def __init__(self, message="", orig_exc_type="", orig_exc_msg=""): # noqa: B042
3939
super().__init__(message)
4040

4141
self.orig_exc_type = orig_exc_type

0 commit comments

Comments
 (0)