Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: "3.10"

- name: Install pip
run: |
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.mypy_cache
__pycache__
.pytest_cache
.coverage
.coverage
.vscode

# poetry lock -- remove if desired to commit lock file
poetry.lock
21 changes: 6 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
install:
@poetry install --all-extras --with dev

lock:
@poetry lock
@poetry install --all-extras --with dev
poetry lock

run:
@poetry run python3 main.py
poetry run python examples/main.py

# Use --check to avoid auto format
fmt:
@poetry run black $(FLAGS) .
@poetry run black src tests

mypy:
@poetry run mypy .

pylint:
@poetry run pylint src

test:
@poetry run pytest
@poetry run mypy src tests

check: fmt mypy
@poetry run prospector --profile prospector.yaml

validate: check
@poetry run coverage run --source=lib -m pytest && \
@poetry run coverage run --source=src -m pytest && \
poetry run coverage report -m
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# End-to-End Python Template
# End-to-End Python Template w/ Poetry
[![v2.0.0](https://img.shields.io/badge/version-v2.0.0-blue.svg)](https://github.com/nachatz/python-template)
[![Test](https://github.com/nachatz/python-template/actions/workflows/validate.yaml/badge.svg)](https://github.com/nachatz/python-template/actions/workflows/validate.yaml)
[![License](https://img.shields.io/badge/license-Apache%202-brightgreen.svg)](https://github.com/nachatz/python-template/blob/master/LICENSE.txt)


This is a Python project template that provides a starting point for building Python applications with essential development tools such as tests, linting, formatting, typing, coverage, and CI/CD setup using Poetry to manage dependencies.

Expand Down Expand Up @@ -90,7 +94,6 @@ To use this template for your Python project, follow these steps:
Run
```bash
make install
make lock`
```

Ensure you have installed **Poetry & Python**
Expand Down Expand Up @@ -133,16 +136,12 @@ This project includes a set of make commands to help you manage your development

- `make install`: Install project dependencies, including development extras.

- `make lock`: Lock project dependencies using Poetry.

- `make fmt`: Format code using Black. Use the FLAGS variable to pass additional formatting options. Example: make fmt FLAGS="--exclude some_folder".

- `make mypy`: Run MyPy type checking.

- `make pylint`: Run pylint for code analysis.

- `make test`: Run pytest for testing.

- `make check`: Run formatting and type checking (fmt and mypy).

- `make validate`: Run full validation, including checks, tests, and coverage.
25 changes: 25 additions & 0 deletions examples/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Python Template Code
~~~~~~~~~~~~~~~~~~~~~

Sample starter code for enabling immediate development of Python applications
utilizing pytest, pylint, black, mypy, and poetry for a sustainable e2e solution.

This showcases working with a Python built library
"""

from project_template.engine import Serializer
from project_template.models import PostModel


def main():
""" Application to fetch a PostModel, update it, and pretty-print the result using
the 'project_template' library.
"""

post: PostModel = Serializer.make_request()
Serializer.update_post(post=post)
Serializer.pretty_print(post=post)

if __name__ == "__main__":
main()
3 changes: 0 additions & 3 deletions lib/engine/__init__.py

This file was deleted.

49 changes: 0 additions & 49 deletions lib/engine/serializer.py

This file was deleted.

3 changes: 0 additions & 3 deletions lib/models/__init__.py

This file was deleted.

24 changes: 0 additions & 24 deletions main.py

This file was deleted.

Loading