Skip to content
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
43 changes: 43 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Purpose
pyqasm is a Python package providing tools to parse, analyze, and manipulate quantum assembly language (QASM) code. The **main purpose of this package is to be "comprehensive"** in its analysis capabilities. This means that while the package may not be the fastest in terms of execution speed, it will provide thorough and detailed analysis of QASM files, ensuring that **all aspects of the language specification are considered.**


## Design Principles

- We aim to use the **SOLID design principles** to ensure that the code is modular, maintainable, and easy to extend. Always give suggestions which are in line with these principles or follow them.

- We heavily rely on the openqasm standard library for parsing and verifying the semantics of QASM code. The Abstract Syntax Tree (AST) generated by the openqasm library is used as the foundation for our semantic analysis. GitHub repo - https://github.com/openqasm/openqasm

- We refer to the QASM specification as the authoritative source for the language's syntax and semantics. The reference can be found at - https://openqasm.com/index.html. Always refer to this specification if there are any ambiguities or uncertainties in the QASM code.

- We intend to provide a simple user interface which is intuitive and easy to use. Always suggest methods and functions that align with this design principle.

## Code Quality
- **We take documentation very seriously**. Every module, class, method, and function should have a docstring that explains its purpose, parameters, and return values. So, when returning responses with code, please ensure that the code is well-documented. Use clear and concise language, and follow the conventions of Python docstrings, example -

```python
def example_function(param1: int, param2: str) -> bool:
"""
Example function that demonstrates the use of docstrings.

Args:
param1 (int): An integer parameter.
param2 (str): A string parameter.

Returns:
bool: Returns True if the parameters are valid, False otherwise.
"""
pass
```

- **We adhere to static typing and use mypy** as the type checker. All functions, methods, and class attributes should have type annotations. Please ensure that the code you provide is compatible with mypy and follows the typing conventions of Python.

- We use **black as the code formatter** to ensure consistent code style. Please format the code you provide using black before returning it. This includes proper indentation, line length, and spacing.

- We use **isort to sort imports** in the code. Please ensure that the imports in the code you provide are sorted using isort.

- Finally, we use **pylint for static code analysis**. Please ensure that the code you provide adheres to pylint's conventions and does not raise any warnings or errors. This includes following naming conventions, avoiding unused variables, and ensuring code readability.

## Error Handling

- We try to be as **granular as possible when it comes to error handling**. We prefer to raise specific exceptions rather than generic ones. While providing code which raises exceptions, please ensure that the exceptions are specific and meaningful. They should provide clear information about the error and how to resolve it.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Types of changes:
- A new discussion template for issues in pyqasm ([#213](https://github.com/qBraid/pyqasm/pull/213))
- A github workflow for validating `CHANGELOG` updates in a PR ([#214](https://github.com/qBraid/pyqasm/pull/214))
- Added `unroll` command support in PYQASM CLI with options skipping files, overwriting originals files, and specifying output paths.([#224](https://github.com/qBraid/pyqasm/pull/224))
- Added `.github/copilot-instructions.md` to the repository to document coding standards and design principles for pyqasm. This file provides detailed guidance on documentation, static typing, formatting, error handling, and adherence to the QASM specification for all code contributions. ([#234](https://github.com/qBraid/pyqasm/pull/234))

### Improved / Modified
- Added `slots=True` parameter to the data classes in `elements.py` to improve memory efficiency ([#218](https://github.com/qBraid/pyqasm/pull/218))
Expand Down