-
Notifications
You must be signed in to change notification settings - Fork 984
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 more check/mypy --next errors #5450
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.
Cool! Thanks!
@@ -314,7 +314,8 @@ def measure_state_vector( | |||
out.shape = initial_shape | |||
out /= np.sqrt(probs[result]) | |||
|
|||
return measurement_bits, out | |||
# We mutate and return out, so mypy cannot identify that the out cannot be None. |
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.
Would it be able to do so if we added assert out is not None
either right here or on line 307 above?
As a matter of principle, I think we should prefer code over comments whenever possible in order to help python/mypy/etc help us :-)
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.
Oh much better thanks!
@@ -314,7 +314,8 @@ def measure_state_vector( | |||
out.shape = initial_shape | |||
out /= np.sqrt(probs[result]) | |||
|
|||
return measurement_bits, out | |||
# We mutate and return out, so mypy cannot identify that the out cannot be None. |
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.
Incidentally, I think the type annotation on out
should be Optional[np.ndarray]
. Might as well fix it while you're in the neighborhood.
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.
Good catch. Fixed.
Automerge cancelled: A status check is failing. |
No description provided.