Skip to content
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

Merged
merged 15 commits into from
Jun 6, 2022
Merged

Conversation

dabacon
Copy link
Collaborator

@dabacon dabacon commented Jun 6, 2022

No description provided.

@dabacon dabacon requested review from wcourtney, a team, vtomole, cduck and verult as code owners June 6, 2022 17:32
@dabacon dabacon requested a review from tanujkhattar June 6, 2022 17:32
@CirqBot CirqBot added the size: M 50< lines changed <250 label Jun 6, 2022
Copy link
Collaborator

@viathor viathor left a 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.
Copy link
Collaborator

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 :-)

Copy link
Collaborator Author

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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 6, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Jun 6, 2022

Automerge cancelled: A status check is failing.

@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 6, 2022
@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 6, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 6, 2022
@CirqBot CirqBot merged commit b5a7cf7 into quantumlib:master Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants