Opentemplate – FOSS Python template –> ease, security, SOTA tooling

4 months ago 14

The simplest to use, yet the most comprehensive Python template

PyPI - Python Version Python Version from PEP 621 TOML License Coverage Hardcoded OSSF-Scorecard Score

Features 🚀 Quick start 📚 Documentation 🤝 Contribute 👍 Adopters 📜 Legal


opentemplate is a Python template which is:

Note

Install pdm (if you don't have it already), for Linux/MacOS:

curl -sSL https://pdm-project.org/install-pdm.py | python3 -
  1. Create a new GitHub repository using this template (green Use this template button)
  2. Name your repo (use underscore _, not hyphens -)
  3. Add project description (necessary!)
  4. Wait until the setup commit appears (performed by github-actions[bot], it may take a few minutes)
  5. Clone the repository
  6. Run pdm setup command locally to setup development environment
  1. Create a new branch
  2. Optionally add dependencies to pyproject.toml
  3. Write code in /src/<project_name> and tests in /tests
  4. Use git add, git commit and git push your changes
  5. pre-commit will guide you through the process
Run checkers or fixers manually (click me)  
> pdm check-<group> # pdm fix-<group>

Note that all check and fix commands are grouped for your convenience:

> pdm check-all # pdm fix-all
Adjust template (click me)  

Most of the adjustments can be done by only editing pyproject.toml

Common changes to pyproject.toml:

  • Add dev dependencies under [dependency-groups] (everything is named dev-<group>)
  • Modify [tool.pdm.scripts] for custom command (check-<group> or fix-<group>, the latter modifies files)
  • Use [tool.<name>] to adjust specific tool configuration

Adjusting these sections will affect pre-commit and GitHub Actions

Disable some pre-commit check (click me)  

Disabling checks should be done cautiously!

pre-commit checks are defined in .pre-commit-config.yaml.

Disable a check using SKIP environment variable:

SKIP='<group1>,<group2>` git commit -m <message>

For details, refer to the id fields in .pre-commit-config.yaml.

Some commands have both <group>-fix and <group>-check for different actions!

We welcome your contributions! Start here:

  • This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
  • This project is copyrighted by open-nudge - the appropriate copyright notice is included in each file.
Read Entire Article