Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a python (package) variant #1

Open
21 tasks
thekaveman opened this issue Aug 1, 2022 · 0 comments
Open
21 tasks

Create a python (package) variant #1

thekaveman opened this issue Aug 1, 2022 · 0 comments

Comments

@thekaveman
Copy link
Member

thekaveman commented Aug 1, 2022

Create another template repository, based on this one, with a basic setup for creating a new Python package.

Features

Running list of features to build into this template

Linting

Use flake8 for python code linting:

  • configuration in .flake8
  • add to .devcontainer/requirements.txt
  • devcontainer plugin, add to devcontainer.json
  • pre-commit hook, add to .pre-commit-config.yaml

Formatting

Use black for python code formatting:

  • configuration in pyproject.toml
  • add to .devcontainer/requirements.txt
  • devcontainer plugin, add to devcontainer.json
  • pre-commit hook, add to .pre-commit-config.yaml

Testing

Use pytest for python testing

  • tests/ dir: __init__.py, conftest.py (empty)
  • tests/requirements.txt, install in devcontainer: pytest, pytest-cov, pytest-mock
  • tests/run.sh: runs tests with coverage, (re)generates coverage report
  • Serve coverage report from docs service
  • .github/workflows/pytest.yml calls tests/run.sh on every commit

Python package setup

  • package_name/ dir: __init__.py (empty)
  • .devcontainer/postAttach.sh, install the local package into the devcontainer
  • setup.py in the root, just import and call setuptools.setup() (with no args)
  • setup.cfg in the root, most configuration info about package
  • [build-system] entry in pyproject.toml

Repository setup

  • .gitignore with at least:
__pycache__/
.pytest_cache/
.coverage
.DS_Store
.egg-info/
build/

Editor settings

  • Add the following to .vscode/settings.json
"[python]": {
  "editor.defaultFormatter": "ms-python.python"
},
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.testing.pytestArgs": ["tests"],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false

Docs

  • Add mkdocstrings for automatic code documentation generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant