You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# python-project-template — showcasing good software practices
7
9
The library provides a small dependence-free Calculator API (Operation, OperationRegistry, Calculator) that can register and compose simple mathematical operations.
8
10
This simple code is used to showcase some good coding practices.
@@ -22,50 +24,48 @@ This simple code is used to showcase some good coding practices.
22
24
23
25
-**Argument validation** with type annotations and runtime checking using the ``typing`` module.
24
26
-**Consistent error messages** for invalid operations and inputs via custom ``Exceptions``.
25
-
-**Unit tests** with ``pytest``. Global testing variables set in :file:`tests/convtest.py`.
27
+
-**Unit tests** with ``pytest``. Global testing variables set in `tests/convtest.py`.
26
28
-**Example notebooks and scripts** for demonstration and exploration.
27
29
-**Google-style documentation** generated with ``sphinx``.
28
-
-**Pre-commit routine** configured in :file:`.pre-commit-config.yaml`:
30
+
-**Pre-commit routine** configured in `.pre-commit-config.yaml`:
29
31
30
32
- Code formatting with ``black``
31
33
- Linting with ``ruff-pre-commit``
32
34
- Type checking with ``mypy``
33
35
- Additional checks and fixes (trailing whitespace removal, enforcing empty line at EOF, YAML syntax checks, blocking large files) via ``pre-commit-hooks``
34
36
35
-
--**Modern packaging** and easy installation using :file:`pyproject.toml`.
36
-
-**Automated test suite and coverage reporting** integrated with GitHub Actions; coverage reports can be published to GitHub Pages. Setup in :file:`.github/workflows/tests.yml`.
37
-
-**Automatic documentation deployment** to GitHub Pages with GitHub Actions. Setup in :file:`.github/workflows/docs.yml`[TODO].
37
+
-**Modern packaging** and easy installation using `pyproject.toml`.
38
+
-**Automated test suite and coverage reporting** integrated with GitHub Actions; coverage reports can be published to GitHub Pages. Setup in `.github/workflows/tests.yml`.
39
+
-**Automatic documentation build and deployment** to GitHub Pages with GitHub Actions. Setup in `.github/workflows/docs.yml`.
38
40
-**Easy contribution workflow** for new features and improvements.
39
41
40
42
## Installation
41
43
42
44
Clone the repository, create a virtual environment (recommended), and install dependencies and an editable installation of `python-project-template`:
This installs the package in editable mode and the development extras (pytest, pre-commit, formatting and linting tools) so you can run tests and linters.
54
-
55
55
## Quick usage
56
56
57
57
The following is a quick example for the Calculator API.
58
58
59
59
```python
60
60
from python_project_template import default_calculator, Operation
61
61
62
-
# Create a default calculator (pre-populated with common ops)
62
+
# Create a default calculator (pre-populated with common operations)
Copy file name to clipboardExpand all lines: docs/features.rst
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,15 @@ This code is used to showcase a number of good software practices:
7
7
- Consistent error messages for invalid operations and inputs via custom ``Exceptions``
8
8
- Unit tests with ``pytest``. Use :file:`tests/convtest.py` to set global testing variables
9
9
- Example notebooks and scripts
10
-
- Google-style documentation with ``sphinx``
10
+
- Google-style documentation generated with ``sphinx``
11
11
- Pre-commit routine set up in file :file:`.pre-commit-config.yaml`. It includes:
12
12
13
13
- Formatting with ``black``
14
14
- Linting with ``ruff`` via pre-commit
15
15
- Type checking with ``mypy``
16
-
- Additional checks and fixes (remove trailing whitespace, ensure one empty line at end of file, YAML syntax checks, prevent committing large files) with ``pre-commit-hooks``
16
+
- Additional checks and fixes (trailing whitespace removal, enforcing empty line at EOF, YAML syntax checks, blocking large files) via ``pre-commit-hooks``
17
17
18
18
- Modern packaging, easy installation, and project settings with :file:`pyproject.toml`
19
19
- Automated test suite and coverage reporting integrated with `GitHub Actions`; coverage reports can be published to `GitHub Pages`. See :file:`.github/workflows/tests.yml`
20
-
- Automatic build and deployment of the documentation to `GitHub Pages` with GitHub Actions. See:file:`.github/workflows/docs.yml`
21
-
- Easy contribution workflow.
20
+
- Automatic documentation build and deployment to `GitHub Pages` with GitHub Actions. Setup in:file:`.github/workflows/docs.yml`
21
+
- Easy contribution workflow for new features and improvements.
The editable installation automatically updates with the source code. It is useful for development because it allows skipping additional installations after source edits.
Copy file name to clipboardExpand all lines: docs/structure.rst
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,18 @@ The project has the following directory structure:
10
10
registry.py # Operation registry
11
11
exceptions.py # Custom error types
12
12
utils.py # Utility functions
13
-
experiments/ # Example scripts
14
-
notebooks/ # Jupyter notebooks
13
+
exampoles/ # Example usage of API
15
14
tests/ # Test suite
16
15
docs/ # Documentation
17
-
.github/
18
-
workflows/
19
-
tests.yml # GitHub Actions workflow for automated testing and coverage reporting
20
-
docs.yml # GitHub Actions workflow for automated documentation and deployment
21
-
pyproject.toml # Build/config file
22
-
README.md # Project overview
23
-
LICENSE # License info
24
-
CITATION.cff # Citation metadata
16
+
.github/workflows/
17
+
tests.yml # GitHub Actions workflow for automated testing and coverage reporting
18
+
docs.yml # GitHub Actions workflow for automated documentation and deployment
19
+
pyproject.toml # Build/config file
20
+
README.md # Project overview
21
+
LICENSE # License info
22
+
CITATION.cff # Citation metadata
23
+
24
+
25
+
.. note::
26
+
27
+
Why is the module inside ``src/``? It prevents accidental imports from the working directory so your tests mirror real installs. This is a widely recommended pattern in the `Python Packaging User Guide <https://packaging.python.org/en/latest/tutorials/packaging-projects/#src-layout>`_.
0 commit comments