|
| 1 | +# Project Overview |
| 2 | + |
| 3 | +`src_method` is a Python package, designed for quantum computing applications. |
| 4 | + |
| 5 | +## General Instructions |
| 6 | + |
| 7 | +- Always prioritize readability and clarity. |
| 8 | +- For algorithm-related code, include explanations of the approach used. |
| 9 | +- Write code with good maintainability practices, including comments on why certain design decisions were made. |
| 10 | +- Handle edge cases and write clear exception handling. |
| 11 | +- For libraries or external dependencies, mention their usage and purpose in comments. |
| 12 | +- Use consistent naming conventions and follow language-specific best practices. |
| 13 | +- Write concise, efficient, and idiomatic code that is also easily understandable. |
| 14 | +- Use conventional commits (ideally with gitmojis) for commit messages. |
| 15 | + |
| 16 | +## Python Coding Conventions |
| 17 | + |
| 18 | +### Python Instructions |
| 19 | + |
| 20 | +- Write code to support Python 3.11, 3.12, 3.13. |
| 21 | +- Write clear and concise comments for each function. |
| 22 | +- Ensure functions have descriptive names and include type hints. |
| 23 | +- Provide docstrings following PEP 257 conventions. |
| 24 | +- Use Google-style docstrings without type annotations (types handled by type hints). |
| 25 | +- Use the `typing` module for type annotations (e.g., `list[str]`, `dict[str, int]`). |
| 26 | +- Break down complex functions into smaller, more manageable functions. |
| 27 | + |
| 28 | +### Code Style and Formatting |
| 29 | + |
| 30 | +- Follow the PEP 8 style guide for Python. |
| 31 | +- Maintain proper indentation (use 4 spaces for each level of indentation). |
| 32 | +- Ensure lines do not exceed 79 characters. |
| 33 | +- Place function and class docstrings immediately after the `def` or `class` keyword. |
| 34 | +- Use blank lines to separate functions, classes, and code blocks where appropriate. |
| 35 | + |
| 36 | +### Edge Cases and Testing |
| 37 | + |
| 38 | +- Always include test cases for critical paths of the application. |
| 39 | +- Account for common edge cases like empty inputs, invalid data types, and large datasets. |
| 40 | +- Include comments for edge cases and the expected behavior in those cases. |
| 41 | +- Write unit tests for functions and document them with docstrings explaining the test cases. |
| 42 | +- Use `pytest` to run tests. |
| 43 | + |
| 44 | +### Example of Proper Documentation |
| 45 | + |
| 46 | +```python |
| 47 | +def calculate_area(radius: float) -> float: |
| 48 | + """Calculate the area of a circle given the radius. |
| 49 | +
|
| 50 | + Args: |
| 51 | + radius: The radius of the circle. |
| 52 | +
|
| 53 | + Returns: |
| 54 | + The area of the circle, calculated as π * radius^2. |
| 55 | + """ |
| 56 | + import math |
| 57 | + return math.pi * radius ** 2 |
| 58 | +``` |
| 59 | + |
| 60 | +## Development Commands |
| 61 | + |
| 62 | +### Environment Setup |
| 63 | + |
| 64 | +- Use `uv` for dependency management. |
| 65 | +- Create the virtual environment with `uv sync --all-groups --all-extras`. |
| 66 | +- Install `pre-commit` hooks to ensure code quality: |
| 67 | +```bash |
| 68 | +uv run pre-commit install --install-hooks |
| 69 | +``` |
| 70 | + |
| 71 | +### Code Quality |
| 72 | + |
| 73 | +- Use `uv run ruff check src/ tests/` for linting. |
| 74 | +- Use `uv run ruff format src/ tests/` for formatting. |
| 75 | +- Use `uv run pre-commit run --all-files` to ensure code quality. |
| 76 | + |
| 77 | +### Testing |
| 78 | + |
| 79 | +- Run the fast tests with `uv run pytest -m "not slow"` |
| 80 | +- Run the slow tests with `uv run pytest -m "slow"` |
| 81 | +- Run the whole test suite with `uv run pytest` |
0 commit comments