lib.wiring: fix equality of FlippedSignature
with other object.
Fixes #882.
This commit is contained in:
parent
cfd4f9c84e
commit
44d5fac01c
|
@ -484,9 +484,11 @@ class FlippedSignature:
|
||||||
return self.flip() == other.flip()
|
return self.flip() == other.flip()
|
||||||
else:
|
else:
|
||||||
# Delegate comparisons back to Signature (or its descendant) by flipping the arguments;
|
# Delegate comparisons back to Signature (or its descendant) by flipping the arguments;
|
||||||
# equality must be reflexive but the implementation of __eq__ need not be, and we can
|
# equality must be reflexive but the implementation of `__eq__` need not be, and we can
|
||||||
# take advantage of it here.
|
# take advantage of it here. This is done by returning `NotImplemented`, otherwise if
|
||||||
return other == self
|
# the other object cannot be compared to a `FlippedSignature` either this will result
|
||||||
|
# in infinite recursion.
|
||||||
|
return NotImplemented
|
||||||
|
|
||||||
# These methods do not access instance variables and so their implementation can be shared
|
# These methods do not access instance variables and so their implementation can be shared
|
||||||
# between the normal and the flipped member collections.
|
# between the normal and the flipped member collections.
|
||||||
|
|
|
@ -832,3 +832,15 @@ class ComponentTestCase(unittest.TestCase):
|
||||||
r"a signature member; did you mean 'val2: In\(MockValueCastable\)' or "
|
r"a signature member; did you mean 'val2: In\(MockValueCastable\)' or "
|
||||||
r"'val2: Out\(MockValueCastable\)'\?$"):
|
r"'val2: Out\(MockValueCastable\)'\?$"):
|
||||||
C3().signature
|
C3().signature
|
||||||
|
|
||||||
|
def test_bug_882(self):
|
||||||
|
class PageBuffer(Component):
|
||||||
|
rand: Signature({}).flip()
|
||||||
|
other: Out(1)
|
||||||
|
|
||||||
|
with self.assertWarnsRegex(SyntaxWarning,
|
||||||
|
r"^Component '.+\.PageBuffer' has an annotation 'rand: Signature\({}\)\.flip\(\)', "
|
||||||
|
r"which is not a signature member; did you mean "
|
||||||
|
r"'rand: In\(Signature\({}\)\.flip\(\)\)' or "
|
||||||
|
r"'rand: Out\(Signature\({}\)\.flip\(\)\)'\?$"):
|
||||||
|
PageBuffer()
|
||||||
|
|
Loading…
Reference in a new issue