enforce Python style
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 160
- Forks
- 113
- Avg merge
- 12d 15h
- Merged PRs (30d)
- 1
Description
#98 mostly talks about C++, but we need this for Python as well, which clang-format doesn't do.
Current status for STIR: #724 and #970 installed all/most infrastructure for clang-format, including pre-commit config. We still haven't run this, pending imminent merge of the TOF PR. Current doc on the process is at https://github.com/UCL/STIR/blob/master/documentation/devel/README.md
Some info from @casperdcl
black: Python & extremely opinionated by design (can only config line length) so I don't tend to use it at all
yapf: Python & configurable
isort: Python import sorting (compatible with above tools)
Also worth mentioning static tools like flake8.
I tend to put config in .pre-commit-config.yaml and pyproject.toml.
I'd also recommend using https://pre-commit.ci which automatically does CI & opens correctional PRs (without needing any additional config).
Example file https://github.com/TomographicImaging/eqt/blob/main/.pre-commit-config.yaml.
Note that we run Codacy which runs Bandit, Prospector, Pylint, but this leaves manual intervention by the user, so it's better to do this via pre-commit of course.
Suggested process:
- PR adding hooks/config/doc, include link to https://github.com/google/yapf/blob/main/EDITOR%20SUPPORT.md in our EDITOR_SUPPORT.md (and others?)
- merge TOF PR to master
- PR run
pre-commitandgit commit --author="pre-commit-format <noreply@github.com>" - use https://pre-commit.ci
- tell everone this will now be enforced, but recommend to set editors accordingly. Ideally we also clean-up/confirm the process by @ashgillman in https://github.com/UCL/STIR/pull/724#issuecomment-848435651 and its follow-up
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 documentation/devel/README.md and the existing pre-commit configuration installed by #724 and #970. Review EDITOR_SUPPORT.md and the proposed yapf, isort, and pre-commit.ci setup, then confirm the TOF PR dependency before deciding the hooks and configuration. Done means Python formatting is configured, documented, and enforced through the proposed commit and CI process.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ci-cd, developer-experience, documentation, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100