tubes
tubes copied to clipboard
Can a function be decorated "tube"? Or only a class?
From the docstring on tube:
"""
L{tube} is a class decorator which declares a given class to be an
implementer of L{ITube} and fills out any methods or attributes which are
not present on the decorated type with null-implementation methods (those
which return None) and None attributes.
@param cls: A class with some or all of the attributes or methods described
by L{ITube}.
However, the readme shows:
@tube
def numbersToLines(value):
yield str(value).encode("ascii")
Indeed, when I try to decorate a function, I get:
zope.interface.exceptions.BrokenMethodImplementation: The implementation of started violates its because implementation requires too many arguments.
That decorator should be @receiver, which is used in various places. @tube is only for classes now. The docs need to be updated.
OK, got it. However, it actually looks like the docs source has already been so updated:
.. literalinclude:: listings/rpn.py
:prepend: @tube
:pyobject: linesToNumbersOrOperators
...and in rpn.py, we have:
@receiver(inputType=IFrame)
def linesToNumbersOrOperators(line):
from operator import add, mul
try:
yield int(line)
except ValueError:
if line == b'+':
yield add
elif line == b'*':
yield mul
Maybe the docs just need to be pushed to RTFD again?
As I recall we reached some kind of resolution on this at PyCon but I don't see it reflected in this or the linked issue…