summaryrefslogtreecommitdiff
path: root/docs/api
diff options
context:
space:
mode:
authorJason Madden <jamadden@gmail.com>2021-04-01 06:59:59 -0500
committerJason Madden <jamadden@gmail.com>2021-04-01 07:11:26 -0500
commiteb542a8a75f93de7f1accbb448820c533bdb4ee3 (patch)
tree6f3ce310979aa71f945db961159eabff65413567 /docs/api
parent4a686fc8d87d398045dc44c1b6a97a2940121800 (diff)
downloadzope-interface-issue193.tar.gz
Make Declaration.__add__ try harder to produce consistent resolution orders.issue193
By moving things from the RHS to the front of the list if they already extend something from the LHS. Fixes #193
Diffstat (limited to 'docs/api')
-rw-r--r--docs/api/declarations.rst32
1 files changed, 18 insertions, 14 deletions
diff --git a/docs/api/declarations.rst b/docs/api/declarations.rst
index cdbf815..4327c72 100644
--- a/docs/api/declarations.rst
+++ b/docs/api/declarations.rst
@@ -763,34 +763,38 @@ Exmples for :meth:`Declaration.__add__`:
.. doctest::
>>> from zope.interface import Interface
- >>> class I1(Interface): pass
+ >>> class IRoot1(Interface): pass
...
- >>> class I2(I1): pass
+ >>> class IDerived1(IRoot1): pass
...
- >>> class I3(Interface): pass
+ >>> class IRoot2(Interface): pass
...
- >>> class I4(I3): pass
+ >>> class IDerived2(IRoot2): pass
...
>>> spec = Declaration()
>>> [iface.getName() for iface in spec]
[]
- >>> [iface.getName() for iface in spec+I1]
- ['I1']
- >>> [iface.getName() for iface in I1+spec]
- ['I1']
+ >>> [iface.getName() for iface in spec+IRoot1]
+ ['IRoot1']
+ >>> [iface.getName() for iface in IRoot1+spec]
+ ['IRoot1']
>>> spec2 = spec
- >>> spec += I1
+ >>> spec += IRoot1
>>> [iface.getName() for iface in spec]
- ['I1']
+ ['IRoot1']
>>> [iface.getName() for iface in spec2]
[]
- >>> spec2 += Declaration(I3, I4)
+ >>> spec2 += Declaration(IRoot2, IDerived2)
>>> [iface.getName() for iface in spec2]
- ['I3', 'I4']
+ ['IDerived2', 'IRoot2']
>>> [iface.getName() for iface in spec+spec2]
- ['I1', 'I3', 'I4']
+ ['IRoot1', 'IDerived2', 'IRoot2']
>>> [iface.getName() for iface in spec2+spec]
- ['I3', 'I4', 'I1']
+ ['IDerived2', 'IRoot2', 'IRoot1']
+ >>> [iface.getName() for iface in (spec+spec2).__bases__]
+ ['IRoot1', 'IDerived2', 'IRoot2']
+ >>> [iface.getName() for iface in (spec2+spec).__bases__]
+ ['IDerived2', 'IRoot2', 'IRoot1']