Skip to content

Be explicit about openqasm3.ast imports #34

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

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-ast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ jobs:
- name: Build package
run: python -m build --wheel --sdist .

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: openpulse-python-wheel
path: ./source/openpulse/dist/*.whl
if-no-files-found: error

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: openpulse-python-sdist
path: ./source/openpulse/dist/*.tar.gz
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-ast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
# The version checker uses 'importlib.metadata' which is Python 3.10+.
python-version: '3.10'

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: openpulse-python-wheel

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: openpulse-python-sdist

Expand Down Expand Up @@ -59,4 +59,4 @@ jobs:
set -e
source .venv/bin/activate
python3 -mpip install -U twine
twine upload openpulse-*.whl openpulse-*.tar.gz
twine upload openpulse-*.whl openpulse-*.tar.gz
2 changes: 1 addition & 1 deletion .github/workflows/tests-ast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: openpulse-python-wheel
path: ./source/openpulse/
Expand Down
2 changes: 1 addition & 1 deletion source/openpulse/openpulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"parse",
]

__version__ = "1.0.0"
__version__ = "1.0.1"

from . import ast, parser, spec
from .parser import parse
174 changes: 172 additions & 2 deletions source/openpulse/openpulse/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,89 @@
from typing import List, Optional, Union

# Re-export the existing AST classes from openqasm3
# pylint: disable=unused-import
from openqasm3.ast import *
# This is everything _except_ CalibrationDefinition
# and CalibrationStatement, which get redefined below.
from openqasm3.ast import (
AccessControl,
AliasStatement,
AngleType,
Annotation,
ArrayLiteral,
ArrayReferenceType,
ArrayType,
AssignmentOperator,
BinaryExpression,
BinaryOperator,
BitType,
BitstringLiteral,
BoolType,
BooleanLiteral,
Box,
BranchingStatement,
BreakStatement,
CalibrationGrammarDeclaration,
Cast,
ClassicalArgument,
ClassicalAssignment,
ClassicalDeclaration,
ClassicalType,
ComplexType,
Concatenation,
ConstantDeclaration,
ContinueStatement,
DelayInstruction,
DiscreteSet,
DurationLiteral,
DurationOf,
DurationType,
EndStatement,
Expression,
ExpressionStatement,
ExternArgument,
ExternDeclaration,
FloatLiteral,
FloatType,
ForInLoop,
FunctionCall,
GateModifierName,
IODeclaration,
IOKeyword,
Identifier,
ImaginaryLiteral,
Include,
IndexExpression,
IndexedIdentifier,
IntType,
IntegerLiteral,
Pragma,
Program,
QASMNode,
QuantumArgument,
QuantumBarrier,
QuantumGate,
QuantumGateDefinition,
QuantumGateModifier,
QuantumMeasurement,
QuantumMeasurementStatement,
QuantumPhase,
QuantumReset,
QuantumStatement,
QubitDeclaration,
RangeDefinition,
ReturnStatement,
SizeOf,
Span,
Statement,
SwitchStatement,
CompoundStatement,
StretchType,
SubroutineDefinition,
TimeUnit,
UintType,
UnaryExpression,
UnaryOperator,
WhileLoop,
)


# From Pulse grammar
Expand Down Expand Up @@ -94,3 +175,92 @@ class CalibrationDefinition(Statement):
qubits: List[Identifier]
return_type: Optional[ClassicalType]
body: List[Statement]


__all__ = [
"AccessControl",
"AliasStatement",
"AngleType",
"Annotation",
"ArrayLiteral",
"ArrayReferenceType",
"ArrayType",
"AssignmentOperator",
"BinaryExpression",
"BinaryOperator",
"BitType",
"BitstringLiteral",
"BoolType",
"BooleanLiteral",
"Box",
"BranchingStatement",
"BreakStatement",
"CalibrationBlock",
"CalibrationDefinition",
"CalibrationGrammarDeclaration",
"CalibrationStatement",
"Cast",
"ClassicalArgument",
"ClassicalAssignment",
"ClassicalDeclaration",
"ClassicalType",
"ComplexType",
"Concatenation",
"ConstantDeclaration",
"ContinueStatement",
"DelayInstruction",
"DiscreteSet",
"DurationLiteral",
"DurationOf",
"DurationType",
"EndStatement",
"Expression",
"ExpressionStatement",
"ExternArgument",
"ExternDeclaration",
"FloatLiteral",
"FloatType",
"ForInLoop",
"FrameType",
"FunctionCall",
"GateModifierName",
"IODeclaration",
"IOKeyword",
"Identifier",
"ImaginaryLiteral",
"Include",
"IndexExpression",
"IndexedIdentifier",
"IntType",
"IntegerLiteral",
"PortType",
"Pragma",
"Program",
"QASMNode",
"QuantumArgument",
"QuantumBarrier",
"QuantumGate",
"QuantumGateDefinition",
"QuantumGateModifier",
"QuantumMeasurement",
"QuantumMeasurementStatement",
"QuantumPhase",
"QuantumReset",
"QuantumStatement",
"QubitDeclaration",
"RangeDefinition",
"ReturnStatement",
"SizeOf",
"Span",
"Statement",
"SwitchStatement",
"CompoundStatement",
"StretchType",
"SubroutineDefinition",
"TimeUnit",
"UintType",
"UnaryExpression",
"UnaryOperator",
"WaveformType",
"WhileLoop",
]
Loading