Add extra python formatting step for imports
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 456
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 165
Description
We currently use yapf to ensure the proper formatting of all .py code. Our initial python implementation used this structure for imports:
- Python future import statements
- Python standard library imports.
- module or package imports.
- Code repository sub-package imports.
With each import getting its own line. E.g, avoiding a single line such as import numpy, scipy, ... . The only exception are relative imports, like from package import thing1, thing2, .... Each block of imports should then be separated by a new-line.
This has slowly gotten out of order over time, so we should automate the import formatting before running yapf. A tool such as isort could be used to do this.
This will likely require the following (subject to evolve):
- Creating some form of custom profile for our import format (maybe relevant)
- Adding the isort command to the bash script in
cuda-quantum/.github/workflows/repo_checks.yml. Specifically here in the python formatting step.
If there are multiple commands needed to run isort, we should consider creating a convenience run_python_format.sh script akin to the scripts/run_clang_format.sh file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python formatting step in .github/workflows/repo_checks.yml around line 127 and review the isort custom-section documentation linked in the issue. Compare the proposed convenience script with scripts/run_clang_format.sh if multiple commands are needed. Done means the repository's Python imports follow the stated grouping and the formatting workflow applies the check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, python
- Domain
- ci-cd, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100