DOC SignalManager docstrings. See GH-713. #1291
Conversation
This change is not 100% backwards compatible because of *args changes. Their usage was not documented, so we're not breaking public interface.
I got bitten by this too, +1 to this change. By looking a little looks like |
def send_catch_log(self, *a, **kw): | ||
kw.setdefault('sender', self.sender) | ||
return signal.send_catch_log(*a, **kw) | ||
.. _deferreds: http://twistedmatrix.com/documents/current/core/howto/defer.html |
curita
Jun 9, 2015
Member
Shouldn't be _deferred
(singular) here? Both mentions of this link are singular, but I think the first line of the docstring of send_catch_log_deferred
should be changed too, it was "... but supports returning deferreds
_ from ..." before.
Probably the links _deferred
and _deferreds
at the bottom of docs/topics/api.rst should be deleted.
Shouldn't be _deferred
(singular) here? Both mentions of this link are singular, but I think the first line of the docstring of send_catch_log_deferred
should be changed too, it was "... but supports returning deferreds
_ from ..." before.
Probably the links _deferred
and _deferreds
at the bottom of docs/topics/api.rst should be deleted.
kmike
Jun 9, 2015
Author
Member
Good catches, fixed. I don't like polluting a docstring with 2 identical links under slightly different names, so the second one is removed.
Good catches, fixed. I don't like polluting a docstring with 2 identical links under slightly different names, so the second one is removed.
LGTM but I don't think we should backport to 1.0. |
Just noticed one more backwards-incompatible change here: previously user was able to omit 'signal' argument in all methods, now it raises an exception. I don't see an use case for omitting 'signal' argument. Found it by calling |
from scrapy.xlib.pydispatch import dispatcher
from scrapy.utils.signal import disconnect_all
sender = object()
signal = object()
def handler():
print("hello")
dispatcher.connect(handler, signal=signal, sender=sender)
dispatcher.send(signal, sender=sender) # prints
disconnect_all(sender=sender)
dispatcher.send(signal, sender=sender) # prints
disconnect_all(signal=signal, sender=sender)
dispatcher.send(signal, sender=sender) # doesn't print |
I'm fine with not backporting it to 1.0. |
previous implementation desconnects all handlers, I see it defaults to |
The example above shows that |
@kmike you're right. |
Should we merge now or are you going to add an exception/warning for the no-signal corner case? |
After this PR an exception is raised if user omits I don't know, maybe there are users of default signal value, so maybe a warning is better. On the other hand, we never documented that a signal can be omitted; I prefer to keep the exception. |
DOC SignalManager docstrings. See GH-713.
This change is not 100% backwards compatible because of
*args
changes. Usage of*args
is not documented, so we're not breaking the public interface. Users of*args
will likely find their code broken if we change (#8) our signals implementation anyways.Generated docs look almost the same as existing; the only difference is that order in which methods are documented is changed.
I got tired looking up what arguments SignalManager methods use - our signals docs is a maze, and source code is not helpful because of
*a, **kw
. Thus this PR :)See also: #713