-
Notifications
You must be signed in to change notification settings - Fork 347
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
Add type annotations to the PauliTerm class #1075
Conversation
Based on #147. |
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.
Please complete the checklist (namely, fill out the changelog).
Paging the resident mypy expert @appleby.
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.
Looks good @rht, thanks for the PR. I noticed in the linked issue there were problems type checking numbers.Number
. Is that still an issue?
Also, does mypy report any errors/warnings when running with --strict
? E.g.
mypy --ignore-missing-imports --follow-imports=silent --strict pyquil/paulis.py
846343d
to
a098b51
Compare
I have added a description of the PR into the changelog. |
There are lots of errors/warnings still because not everything inside paulis.py has been annotated yet. Hopefully the number of errors/warnings become tractable as more of the functions become annotated. |
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.
Minor stuff. Otherwise looks good.
Github won't let me comment on lines that don't have diff, so mentioning here: there appear to be a handful of PauliTerm
methods that are missing return type hints. (I suspect these methods were added after your original PR.) Would you mind adding type hints for them? E.g.
operations_as_set
__hash__
program
__iter__
@appleby I have applied your patches to the PR. I will add annotations to the remaining 4 methods, and I will report when I'm done. |
@appleby I added |
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.
two more small changes; otherwise looks good.
f0d95f6
to
54c6b7e
Compare
The second commit has been squashed. |
There is an inconsistency with |
Given this mypy issue that you pointed out in #147, which seems to imply that |
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.
There are still some issues to work out, mostly around the arithmetic operations, but I think that is an issue of mypy needing more help to correctly infer types. The types added in this PR look reasonable, so I feel OK taking a gradual approach and adding more type hints to the module in a follow on PR.
There is an extra complication due to the fact that the code uses |
I already have |
I will give this a review as soon as I've gotten @appleby's typing PR over the line -- thanks for doing this! :) |
I just rebased to get rid of the merge conflict. @karalekas any update? |
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.
@rht this looks great, and I'm looking forward to the follow-on PR. only thing that needs changing is moving your changelog entry to the new v2.14
"Improvements and Changes" section, which will require you to rebase off of master first
@karalekas rebased and moved the line to be under |
@rht thanks for contributing to pyQuil! :) |
Description
Only PauliTerm is annotated to keep this PR small.
Checklist
auto-close keywords.
including author and PR number (@username, gh-xxx).