diff options
| author | Jason Madden <jamadden@gmail.com> | 2020-04-23 06:11:50 -0500 |
|---|---|---|
| committer | Jason Madden <jamadden@gmail.com> | 2020-04-23 06:11:50 -0500 |
| commit | 5da431f3d2e5c6bda451bfcce6719e7a936a11fb (patch) | |
| tree | b9be9709444f12b10d0a5da3b2b20e8d7955f41e /src/zope/interface/interfaces.py | |
| parent | 10a951f9db32c3e3a29fef4e8b72e354b0c80047 (diff) | |
| download | zope-interface-issue208.tar.gz | |
Fix interface definitions of IAdapterRegistry.subscribe, subscribers and subscriptions.issue208
They were defined to accept a name argument, but the actual implementation doesn't. Add tests for this. Fixes #208.
Also in test_adapter.py modernize idioms from assertTrue(x in y) and assertTrue(x is y) to assertIn and assertIs.
Diffstat (limited to 'src/zope/interface/interfaces.py')
| -rw-r--r-- | src/zope/interface/interfaces.py | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/src/zope/interface/interfaces.py b/src/zope/interface/interfaces.py index 9334374..eb08657 100644 --- a/src/zope/interface/interfaces.py +++ b/src/zope/interface/interfaces.py @@ -42,6 +42,9 @@ __all__ = [ 'IUtilityRegistration', ] +# pylint:disable=inherit-non-class,no-method-argument,no-self-argument +# pylint:disable=unexpected-special-method-signature +# pylint:disable=too-many-lines class IElement(Interface): """ @@ -55,12 +58,14 @@ class IElement(Interface): :class:`ISpecification`). """ + # pylint:disable=arguments-differ + # Note that defining __doc__ as an Attribute hides the docstring # from introspection. When changing it, also change it in the Sphinx # ReST files. __name__ = Attribute('__name__', 'The object name') - __doc__ = Attribute('__doc__', 'The object doc string') + __doc__ = Attribute('__doc__', 'The object doc string') ### # Tagged values. @@ -174,8 +179,8 @@ class IMethod(IAttribute): class ISpecification(Interface): """Object Behavioral specifications""" - - def providedBy(object): + # pylint:disable=arguments-differ + def providedBy(object): # pylint:disable=redefined-builtin """Test whether the interface is implemented by the object Return true of the object asserts that it implements the @@ -334,8 +339,8 @@ class IInterface(ISpecification, IElement): attributes for details. """ - - def names(all=False): + # pylint:disable=arguments-differ + def names(all=False): # pylint:disable=redefined-builtin """Get the interface attribute names Return a collection of the names of the attributes, including @@ -346,7 +351,7 @@ class IInterface(ISpecification, IElement): attributes defined by base classes will be included. """ - def namesAndDescriptions(all=False): + def namesAndDescriptions(all=False): # pylint:disable=redefined-builtin """Get the interface attribute names and descriptions Return a collection of the names and descriptions of the @@ -476,7 +481,7 @@ class IInterfaceDeclaration(Interface): This interface is implemented by :mod:`zope.interface`. """ - + # pylint:disable=arguments-differ ### # Defining interfaces ### @@ -656,7 +661,7 @@ class IInterfaceDeclaration(Interface): .. seealso:: `zope.interface.implementer_only` """ - def directlyProvidedBy(object): + def directlyProvidedBy(object): # pylint:disable=redefined-builtin """ Return the interfaces directly provided by the given object. @@ -665,7 +670,7 @@ class IInterfaceDeclaration(Interface): .. seealso:: `zope.interface.directlyProvidedBy` """ - def directlyProvides(object, *interfaces): + def directlyProvides(object, *interfaces): # pylint:disable=redefined-builtin """ Declare interfaces declared directly for an object. @@ -709,7 +714,7 @@ class IInterfaceDeclaration(Interface): .. seealso:: `zope.interface.directlyProvides` """ - def alsoProvides(object, *interfaces): + def alsoProvides(object, *interfaces): # pylint:disable=redefined-builtin """ Declare additional interfaces directly for an object. @@ -724,7 +729,7 @@ class IInterfaceDeclaration(Interface): .. seealso:: `zope.interface.alsoProvides` """ - def noLongerProvides(object, interface): + def noLongerProvides(object, interface): # pylint:disable=redefined-builtin """ Remove an interface from the list of an object's directly provided interfaces. @@ -958,11 +963,11 @@ class IAdapterRegistry(Interface): text. """ - def queryAdapter(object, provided, name=u'', default=None): + def queryAdapter(object, provided, name=u'', default=None): # pylint:disable=redefined-builtin """Adapt an object using a registered adapter factory. """ - def adapter_hook(provided, object, name=u'', default=None): + def adapter_hook(provided, object, name=u'', default=None): # pylint:disable=redefined-builtin """Adapt an object using a registered adapter factory. name must be text. @@ -974,11 +979,11 @@ class IAdapterRegistry(Interface): An iterable object is returned that provides name-value two-tuples. """ - def names(required, provided): + def names(required, provided): # pylint:disable=arguments-differ """Return the names for which there are registered objects """ - def subscribe(required, provided, subscriber, name=u''): + def subscribe(required, provided, subscriber): # pylint:disable=arguments-differ """Register a subscriber A subscriber is registered for a *sequence* of required @@ -986,17 +991,29 @@ class IAdapterRegistry(Interface): Multiple subscribers may be registered for the same (or equivalent) interfaces. + + .. versionchanged:: 5.1.1 + Correct the method signature to remove the ``name`` parameter. + Subscribers have no names. """ - def subscriptions(required, provided, name=u''): + def subscriptions(required, provided): """Get a sequence of subscribers - Subscribers for a *sequence* of required interfaces, and a provided + Subscribers for a **sequence** of *required* interfaces, and a *provided* interface are returned. + + .. versionchanged:: 5.1.1 + Correct the method signature to remove the ``name`` parameter. + Subscribers have no names. """ - def subscribers(objects, provided, name=u''): + def subscribers(objects, provided): """Get a sequence of subscription adapters + + .. versionchanged:: 5.1.1 + Correct the method signature to remove the ``name`` parameter. + Subscribers have no names. """ # begin formerly in zope.component @@ -1020,9 +1037,10 @@ class IObjectEvent(Interface): @implementer(IObjectEvent) class ObjectEvent(object): - def __init__(self, object): + def __init__(self, object): # pylint:disable=redefined-builtin self.object = object + class IComponentLookup(Interface): """Component Manager for a Site @@ -1036,13 +1054,13 @@ class IComponentLookup(Interface): utilities = Attribute( "Adapter Registry to manage all registered utilities.") - def queryAdapter(object, interface, name=u'', default=None): + def queryAdapter(object, interface, name=u'', default=None): # pylint:disable=redefined-builtin """Look for a named adapter to an interface for an object If a matching adapter cannot be found, returns the default. """ - def getAdapter(object, interface, name=u''): + def getAdapter(object, interface, name=u''): # pylint:disable=redefined-builtin """Look for a named adapter to an interface for an object If a matching adapter cannot be found, a `ComponentLookupError` @@ -1191,7 +1209,7 @@ class IUnregistered(IRegistrationEvent): class Unregistered(RegistrationEvent): """A component or factory was unregistered """ - pass + class IComponentRegistry(Interface): """Register components @@ -1266,7 +1284,7 @@ class IComponentRegistry(Interface): """ def registerAdapter(factory, required=None, provided=None, name=u'', - info=u''): + info=u''): """Register an adapter factory :param factory: |
