New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix type error in (X/Y)PowGate._act_on_ #3533
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are changing this to avoid type: ignore
s, might as well fix the same pattern in YPowGate
for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good - though I do like the list comprehension as it's a bit more python-esque.
An alternative way to keep it is to actually use the protocol type in the type definition:
ops = [ZPowGate(), H] # type: List[SupportsActOn]
assert all(gate._act_on_(args) for gate in ops)
What do you think of this direction?
@balopat, I added a helper function to call |
There was a type error due to the fact that the common superclass
EigenGate
does not define_act_on_
. We can act on each gate instead of looping over them, which avoids the type error.