-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactoring the Qasm3Visitor
#142
Conversation
2770f7b
to
d314d80
Compare
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
- Let's remove the
qasm3.utils.imports
file and instead use namespace imports inqasm3.visitor
and other files that have big import blocks. - Please refactor to eliminate any ascending relative imports. This can be done either by moving all of files within
qasm3.utils
up to theqasm3
module level, or potentially with some clever inversion of the module structure. In the former, there would still only be 8 python files within the top-levelqasm3
module, which isn't that bad.
See comments below.
6e7fbe7
to
8e979d2
Compare
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.
Overall looking much better! Last few things to address which I mention in more detail below:
- Making sure all functions have appropriate type hints (this will also help make Add static type checking with
mypy
#145 easier) - Combine in the
print_err_location
and exception raising by either modifying the existingQasm3ConversionError
exception class or creating a helper function that both raises the exception and logs/prints the element line/column traceback. - Rename the
visitor_utils
file andQasm3VisitorUtils
class to something a bit more descriptive. Regroup validators / analyzers / transformers as necessary.
qbraid_qir/qasm3/expressions.py
Outdated
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 add type hints to all methods to comply with py.typed
|
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.
These updates look great! If you could just address the two lines of unreachable code I noted below either by updating the typehint, or removing them. After that it should be good
Edit: Also, is the supported conversions table up to date? And if not, could you update it? Thanks!
Sure, will change. Also, some type hints are still left but I'll address them in the |
de11571
to
ecc82d7
Compare
Fixes #136
Summary of changes
Qasm3Visitor
. These were independent of theself
and moved out to a separate utility class. Moreover, it made sense to keep all the_visit_*
methods in the visitor.openqasm3
were also moved to a different fileGateUtils
,VariableUtils
, etc. but felt a bit of an overkill@ryanhill1 would like to hear your thoughts on this too, thanks!