From 163c48585e5fe7300c4fac53d4dce6e4e7976186 Mon Sep 17 00:00:00 2001 From: Ben Trachtenberg Date: Sun, 16 Nov 2025 11:22:43 -0600 Subject: [PATCH 1/2] added mypy --- cookiecutter.json | 2 +- {{cookiecutter.git_repo_name}}/Makefile | 15 +++++++++++---- {{cookiecutter.git_repo_name}}/make.bat | 15 ++++++++++++++- {{cookiecutter.git_repo_name}}/pyproject.toml | 4 ++-- .../requirements-dev.txt | 1 + 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 5be77a9..6c701ca 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -48,7 +48,7 @@ "https" ], "__template_repo": "https://github.com/btr1975/cookiecutter-python-library", - "__template_version": "2.0.3", + "__template_version": "2.0.4", "_new_lines": "\n", "_copy_without_render": [ ".github" diff --git a/{{cookiecutter.git_repo_name}}/Makefile b/{{cookiecutter.git_repo_name}}/Makefile index 9232675..e522eda 100644 --- a/{{cookiecutter.git_repo_name}}/Makefile +++ b/{{cookiecutter.git_repo_name}}/Makefile @@ -1,10 +1,10 @@ # Makefile for project needs # Author: Ben Trachtenberg -# Version: 2.0.0 +# Version: 2.0.1 # .PHONY: all info build build-container coverage format pylint pytest start-container stop-container remove-container \ - gh-pages check-vuln pip-export + gh-pages check-vuln pip-export mypy info: @echo "make options" @@ -15,6 +15,7 @@ info: @echo " check-security To check for vulnerabilities in the code" @echo " coverage To run coverage and display ASCII and output to htmlcov" @echo " format To format the code with black" + @echo " mypy To run mypy" @echo " pylint To run pylint" @echo " pytest To run pytest with verbose option" @echo " start-container To start the container" @@ -24,7 +25,7 @@ info: {% if cookiecutter.package_manager == 'pip' %} -all: format pylint coverage check-security check-vuln +all: format pylint mypy coverage check-security check-vuln build: @python -m build @@ -48,6 +49,9 @@ check-vuln: check-security: @bandit -c pyproject.toml -r . +mypy: + @mypy {{cookiecutter.__library_name}}/ + {% if cookiecutter.library_documents_location == 'github-pages' %} gh-pages: @rm -rf ./docs/source/code @@ -57,7 +61,7 @@ gh-pages: {% elif cookiecutter.package_manager == 'uv' %} -all: format pylint coverage check-security pip-export +all: format pylint mypy coverage check-security pip-export build: @uv build --wheel --sdist @@ -78,6 +82,9 @@ pytest: check-security: @uv run bandit -c pyproject.toml -r . +mypy: + @uv run mypy {{cookiecutter.__library_name}}/ + pip-export: @uv export --no-dev --no-emit-project --no-editable > requirements.txt @uv export --no-emit-project --no-editable > requirements-dev.txt diff --git a/{{cookiecutter.git_repo_name}}/make.bat b/{{cookiecutter.git_repo_name}}/make.bat index c3ac28b..e3a5233 100644 --- a/{{cookiecutter.git_repo_name}}/make.bat +++ b/{{cookiecutter.git_repo_name}}/make.bat @@ -1,7 +1,7 @@ @ECHO OFF REM Makefile for project needs REM Author: Ben Trachtenberg -REM Version: 2.0.0 +REM Version: 2.0.1 REM SET option=%1 @@ -16,6 +16,7 @@ IF "%option%" == "all" ( black {{cookiecutter.__library_name}}/ black tests/ pylint {{cookiecutter.__library_name}}\ + mypy {{cookiecutter.__library_name}}\ pytest --cov --cov-report=html -vvv bandit -c pyproject.toml -r . pip-audit -r requirements.txt @@ -58,6 +59,11 @@ IF "%option%" == "check-security" ( GOTO END ) +IF "%option%" == "mypy" ( + mypy {{cookiecutter.__library_name}}\ + GOTO END +) + {% if cookiecutter.library_documents_location == 'github-pages' %} IF "%option%" == "gh-pages" ( rmdir /s /q docs\source\code @@ -73,6 +79,7 @@ IF "%option%" == "all" ( uv run black {{cookiecutter.__library_name}}/ uv run black tests/ uv run pylint {{cookiecutter.__library_name}}\ + uv run mypy {{cookiecutter.__library_name}}\ uv run pytest --cov --cov-report=html -vvv uv run bandit -c pyproject.toml -r . uv export --no-dev --no-emit-project --no-editable > requirements.txt @@ -111,6 +118,11 @@ IF "%option%" == "check-security" ( GOTO END ) +IF "%option%" == "mypy" ( + uv run mypy {{cookiecutter.__library_name}}\ + GOTO END +) + IF "%option%" == "pip-export" ( uv export --no-dev --no-emit-project --no-editable > requirements.txt uv export --no-emit-project --no-editable > requirements-dev.txt @@ -136,6 +148,7 @@ IF "%option%" == "gh-pages" ( @ECHO check-vuln To check for vulnerabilities in the dependencies @ECHO check-security To check for vulnerabilities in the code @ECHO format To format the code with black +@ECHO mypy To run mypy @ECHO pylint To run pylint @ECHO pytest To run pytest with verbose option {% if cookiecutter.package_manager == 'uv' %}@ECHO pip-export To export the requirements.txt and requirements-dev.txt{% endif %} diff --git a/{{cookiecutter.git_repo_name}}/pyproject.toml b/{{cookiecutter.git_repo_name}}/pyproject.toml index 9de9375..727a8b5 100644 --- a/{{cookiecutter.git_repo_name}}/pyproject.toml +++ b/{{cookiecutter.git_repo_name}}/pyproject.toml @@ -56,8 +56,7 @@ classifiers = [ {% if cookiecutter.minimum_python_version == '3.12' %}"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14",{% endif -%} - {% if cookiecutter.minimum_python_version == '3.13' %} - "Programming Language :: Python :: 3.13", + {% if cookiecutter.minimum_python_version == '3.13' %}"Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14",{% endif -%} {% if cookiecutter.minimum_python_version == '3.14' %}"Programming Language :: Python :: 3.14",{% endif -%} @@ -80,6 +79,7 @@ dev = [ "sphinx_rtd_theme", "sphinxcontrib-mermaid", "bandit", + "mypy", {% if cookiecutter.use_requests == 'y' %}"requests-mock",{% endif %} ] {% endif %} diff --git a/{{cookiecutter.git_repo_name}}/requirements-dev.txt b/{{cookiecutter.git_repo_name}}/requirements-dev.txt index 20568d0..96643b9 100644 --- a/{{cookiecutter.git_repo_name}}/requirements-dev.txt +++ b/{{cookiecutter.git_repo_name}}/requirements-dev.txt @@ -14,4 +14,5 @@ sphinx_rtd_theme sphinxcontrib-mermaid twine bandit +mypy {% if cookiecutter.use_requests == 'y' %}requests-mock{% endif %} From f3c2303f7dd747eb92d60dd7c78565b877e76e51 Mon Sep 17 00:00:00 2001 From: Ben Trachtenberg Date: Sun, 16 Nov 2025 11:53:52 -0600 Subject: [PATCH 2/2] updated for Windows runner testing issue --- .github/workflows/test-bake.yml | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-bake.yml b/.github/workflows/test-bake.yml index f090fba..f203ec8 100644 --- a/.github/workflows/test-bake.yml +++ b/.github/workflows/test-bake.yml @@ -21,12 +21,10 @@ on: jobs: build: - runs-on: ${{ matrix.os }} strategy: matrix: python-version: - - "3.9" - "3.10" - "3.11" - "3.12" @@ -34,7 +32,6 @@ jobs: - "3.14" os: - ubuntu-latest - - windows-latest - macos-latest steps: @@ -58,3 +55,38 @@ jobs: - name: Check Vulnerabilities run: | pip-audit -r requirements.txt + + build-windows: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: + - "3.10" + - "3.11" + - "3.12" + - "3.13" + - "3.14" + os: + - windows-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip setuptools wheel + run: | + python -m pip install --upgrade pip setuptools wheel + - name: Install requirements from requirements-dev.txt + run: | + python -m pip install -r requirements-dev.txt + - name: Run Testing + run: | + pytest --cov -vvv + - name: Run Linting + run: | + pylint hooks/ + - name: Check Vulnerabilities + run: | + pip-audit -r requirements.txt