File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -484,9 +484,11 @@ def __eq__(self, other):
484484 return self .flip () == other .flip ()
485485 else :
486486 # Delegate comparisons back to Signature (or its descendant) by flipping the arguments;
487- # equality must be reflexive but the implementation of __eq__ need not be, and we can
488- # take advantage of it here.
489- return other == self
487+ # equality must be reflexive but the implementation of `__eq__` need not be, and we can
488+ # take advantage of it here. This is done by returning `NotImplemented`, otherwise if
489+ # the other object cannot be compared to a `FlippedSignature` either this will result
490+ # in infinite recursion.
491+ return NotImplemented
490492
491493 # These methods do not access instance variables and so their implementation can be shared
492494 # between the normal and the flipped member collections.
Original file line number Diff line number Diff line change @@ -832,3 +832,15 @@ class C3(Component):
832832 r"a signature member; did you mean 'val2: In\(MockValueCastable\)' or "
833833 r"'val2: Out\(MockValueCastable\)'\?$" ):
834834 C3 ().signature
835+
836+ def test_bug_882 (self ):
837+ class PageBuffer (Component ):
838+ rand : Signature ({}).flip ()
839+ other : Out (1 )
840+
841+ with self .assertWarnsRegex (SyntaxWarning ,
842+ r"^Component '.+\.PageBuffer' has an annotation 'rand: Signature\({}\)\.flip\(\)', "
843+ r"which is not a signature member; did you mean "
844+ r"'rand: In\(Signature\({}\)\.flip\(\)\)' or "
845+ r"'rand: Out\(Signature\({}\)\.flip\(\)\)'\?$" ):
846+ PageBuffer ()
You can’t perform that action at this time.
0 commit comments