From 420e3739c5593c3cf1577d8db87cf154265a2f6b Mon Sep 17 00:00:00 2001 From: eol Date: Tue, 15 Apr 2025 09:58:07 +0700 Subject: [PATCH 1/8] Removing taskipy as required installation (it is installed with [dev]) --- {{cookiecutter.project_slug}}/README.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index b88a1e5..cd993e7 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -76,16 +76,11 @@ To run this project locally, you will need to install the prerequisites and foll ### Prerequisites This Project depends on the following projects. -* UV +* uv ```sh pip install --user --upgrade uv ``` -* Taskipy - ```sh - pip install --user --upgrade taskipy - ``` - ### Installation 1. Clone the repo @@ -93,9 +88,9 @@ This Project depends on the following projects. git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.project_slug}} cd {{cookiecutter.project_slug}} ``` -2. Install UV and taskipy +2. Install uv ```sh - pip install --user --upgrade uv taskipy + pip install --user --upgrade uv ``` 3. Install requirements for development ```sh From 527d1c74c3cab62b5505167bc3f45ea054674ed2 Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 19 Apr 2025 16:05:44 +0700 Subject: [PATCH 2/8] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 84215fb..e1e755a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Python template with some awesome tools to quickstart a Python project with the industry best practices. It includes automatic generation of API documentation, tests using PyTest, code coverage, -ruff linting to enforce standardized Python coding and formatting, virtual environments using UV, workflow automation using Taskipy and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers. +ruff linting to enforce standardized Python coding and formatting, virtual environments using uv, workflow automation using Taskipy and a space optimized Dockerfile to kickstart your project and run tests using the power of Docker containers. You only need to install [Cookiecutter](https://cookiecutter.readthedocs.io/en/1.7.2/usage.html)! @@ -90,12 +90,13 @@ This Project depends on the following projects. cookiecutter https://github.com/nullhack/python-project-template # move into your newly created project folder ``` -2. Install UV and Taskipy +2. Install uv and Taskipy ```sh - pip install --user --upgrade uv taskipy + pip install --user --upgrade uv ``` 3. Let Taskipy do it's magic ```sh + uv venv uv pip install .[dev] uv task test uv task run From 7d02397711e110df702c15fa9880c3f8a6bcca8e Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 19 Apr 2025 16:08:48 +0700 Subject: [PATCH 3/8] Update README.md --- {{cookiecutter.project_slug}}/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index cd993e7..d0a6952 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -113,6 +113,8 @@ Some useful examples of how this project can be used: * Install requirements ```sh + pip install --user --upgrade uv + uv venv uv run task '.[dev]' ``` @@ -123,7 +125,7 @@ Some useful examples of how this project can be used: * Run the project ```sh - uv run main.py + uv run task run ``` * Generate API documentation From 36bc79471b9d4326a4bada52014fd2c8f9fa0ed6 Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 19 Apr 2025 16:11:02 +0700 Subject: [PATCH 4/8] Update README.md --- {{cookiecutter.project_slug}}/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index d0a6952..36bfc4f 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -113,9 +113,8 @@ Some useful examples of how this project can be used: * Install requirements ```sh - pip install --user --upgrade uv uv venv - uv run task '.[dev]' + uv pip install '.[dev]' ``` * Run tests From 9eb6ba5d125a861a632db4ba7a713c0570e79068 Mon Sep 17 00:00:00 2001 From: eol Date: Fri, 25 Apr 2025 22:20:29 +0700 Subject: [PATCH 5/8] Improving pytest with markers and run smoke and unit tests before others --- {{cookiecutter.project_slug}}/pyproject.toml | 39 +++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 5af9d23..d36a6a2 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -76,17 +76,23 @@ pydocstyle.convention = "google" [tool.pytest.ini_options] minversion = "6.0" +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "unit", + "integration", + "system", + "acceptance", + "regression", + "smoke", + "sanity", + "performance", + "security", + "performance", +] addopts = """ --maxfail=1 \ --color=yes \ ---cov={{cookiecutter.package_name}} \ ---html=docs/pytest_report.html \ ---self-contained-html \ ---cov-fail-under={{cookiecutter.minimum_coverage}} \ ---cov-report term-missing \ ---cov-report html:docs/cov-report \ ---doctest-modules \ ---cov-config=pyproject.toml""" +""" testpaths = [ "tests", "{{cookiecutter.package_name}}" @@ -110,7 +116,22 @@ exclude_lines = [ [tool.taskipy.tasks] run = "python -m {{cookiecutter.package_name}}.{{cookiecutter.module_name}}" -test = "pytest" +test-report = """\ +pytest \ + --cov-config=pyproject.toml \ + --doctest-modules \ + --cov-fail-under=90 \ + --cov-report=term-missing \ + --cov-report=html:docs/cov-report \ + --html=docs/pytest_report.html \ + --self-contained-html\ +""" +test = """\ +python -c "import subprocess, sys; print('Running Smoke Tests...'); sys.exit(0 if subprocess.run(['pytest', '-m', 'smoke']).returncode in (0,5) else 1)" && \ +python -c "import subprocess, sys; print('Running Unit Tests...'); sys.exit(0 if subprocess.run(['pytest', '-m', 'unit']).returncode in (0,5) else 1)" && \ +python -c "print('Running Tests...');" && \ +task test-report\ +""" ruff-check = "ruff check **/*.py --fix" ruff-format = "ruff format **/*.py" lint = "task ruff-check && task ruff-format" From 032eec868b7721b676e3ee8f06b47a6711b926b6 Mon Sep 17 00:00:00 2001 From: eol Date: Fri, 25 Apr 2025 22:34:35 +0700 Subject: [PATCH 6/8] Including more resources in pytest --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e1e755a..277640a 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ This project was heavily based on some great references. * [5 Pytest Best Practices for Writing Great Python Tests](https://www.nerdwallet.com/blog/engineering/5-pytest-best-practices/) * [Best-README-Template](https://github.com/othneildrew/Best-README-Template) * [Beyond Hypermodern: Python is easy now (2024)](https://rdrn.me/postmodern-python/) +* [Pytest Best Practices](https://pytest-with-eric.com/)

(back to top)

From 4b775cd50d99b85619dce05eaa8d0150cedf4f21 Mon Sep 17 00:00:00 2001 From: eol Date: Sat, 26 Apr 2025 00:01:20 +0700 Subject: [PATCH 7/8] Improving documentation with light and dark versions --- {{cookiecutter.project_slug}}/docs/mkdocs.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/docs/mkdocs.yaml b/{{cookiecutter.project_slug}}/docs/mkdocs.yaml index d86b542..f96048c 100644 --- a/{{cookiecutter.project_slug}}/docs/mkdocs.yaml +++ b/{{cookiecutter.project_slug}}/docs/mkdocs.yaml @@ -27,8 +27,18 @@ theme: palette: - media: '(prefers-color-scheme: light)' scheme: default - primary: blue + primary: indigo accent: amber + toggle: + icon: material/toggle-switch-off-outline + name: Switch to dark mode + - media: '(prefers-color-scheme: dark)' + scheme: slate + primary: indigo + accent: amber + toggle: + icon: material/toggle-switch + name: Switch to light mode atures: - search.suggest - search.highlight From 6c69532bfc30635e37b178670de87bc7a44bd362 Mon Sep 17 00:00:00 2001 From: eol Date: Sun, 27 Apr 2025 11:20:47 +0700 Subject: [PATCH 8/8] Including dockerignore file --- {{cookiecutter.project_slug}}/.dockerignore | 174 ++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/.dockerignore diff --git a/{{cookiecutter.project_slug}}/.dockerignore b/{{cookiecutter.project_slug}}/.dockerignore new file mode 100644 index 0000000..8751745 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.dockerignore @@ -0,0 +1,174 @@ +.github + +DS_Store +.coverage +.vscode/\n.idea/ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Remove html generated by documentation + +docs/html + +# Remove tests and coverage reports +docs/cov-report +docs/pytest_report.html + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ +