-
Notifications
You must be signed in to change notification settings - Fork 9
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 API, type hints for existing bindings. #168
Merged
MarquessV
merged 25 commits into
1455-python-support-for-program-and-beyond
from
167-add-instruction-api-type-hints-for-existing-bindings
Mar 16, 2023
Merged
Add API, type hints for existing bindings. #168
MarquessV
merged 25 commits into
1455-python-support-for-program-and-beyond
from
167-add-instruction-api-type-hints-for-existing-bindings
Mar 16, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MarquessV
commented
Mar 15, 2023
kalzoo
approved these changes
Mar 16, 2023
MarquessV
deleted the
167-add-instruction-api-type-hints-for-existing-bindings
branch
March 16, 2023 23:45
This was referenced Mar 17, 2023
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a pretty large PR, but the approach was very mechanical.
For any existing module in
quil-py
:I checked that it mirrored
quil-rs
, and if not, reconciled them to match. In most cases, this was a matter of refactoringquil-rs
instructions out ofmod.rs
and into a submodule. There were a few cases wherequil-py
had a module in the wrong place. For example, theexpression
module was ininstructions
instead of it's own top-level module. In these cases, I refactoredquil-py
to match.Made sure each binding had a
new
constructor, derived the same attributes as its correspondingquil-rs
type, and wasn't missing any derived implementations (e.g.impl_hash!
forHash
orfn __richcmp__
forPartialEq
/Eq
).Added missing variants to the
PyInstruction
enum, if the module contained any of the needed types.Made sure they all had type hints and didn't fail any
stubtest
checks. As part of this I had to flatten the type stubs. We can't break them into private modules for organization because those private modules aren't actually exported by the package. Technically, there are still twostubtest
failures. The bindings exportquil.quil
andquil.validation.quil.validation.identifier
as empty modules. I've seen this in theqcs_sdk
as well, and I think it's a bug with either the pyo3 macros or pyo3 itself. We could silence the errors by adding dummy stubs, but I'd rather have the errors and not expose them to users. I created this issue to follow-up.I also handled a few extra things, like building out the
Expression
bindings, because they were in the path and it made sense to just get it out of the way here.Closes #167, and because the frame instruction bindings were pre-existing, this also closes #162. This also adds a
Makefile.toml
with a workflow for runningstubtest
to validate the type stubs.