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

refactor(no-release): make mypy standalone #608

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 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
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ RUN if [ "${PYTHON_VERSION}" = "3.8" ]; then \
pipx install pre-commit==3.7.1; \
fi

# Install prerequisites
RUN --mount=source=Makefile,target=Makefile \
make prerequisites

# Create a non-root user with sudo permission
ARG USERNAME=ss-python
ARG USER_UID=1000
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*
.*
!/Makefile
!/README.md
!/pdm.lock
!/pyproject.toml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
python-version: ${{ matrix.python-version }}
version: 2.15.4
- run: env | sort
- run: make prerequisites
- run: make dev
- run: make lint test doc build
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitlab/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ci:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- make prerequisites
- make dev
- make lint test doc build
stage: ci
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repos:
pass_filenames: false
- id: mypy
name: mypy
entry: pdm run python -m mypy
entry: mypy --python-executable $(pdm info --python)
msclock marked this conversation as resolved.
Show resolved Hide resolved
language: system
exclude: ^template/.*
types_or:
Expand Down
9 changes: 5 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build:
apt_packages:
- pipx
jobs:
post_checkout:
- git fetch --unshallow || true
Expand All @@ -20,13 +22,12 @@ build:
post_system_dependencies:
- env | sort
pre_create_environment:
- asdf plugin add pdm
- asdf install pdm 2.15.4
- asdf global pdm 2.15.4
- PIPX_BIN_DIR=$READTHEDOCS_VIRTUALENV_PATH/bin pipx install mypy[reports]==1.10.1
- PIPX_BIN_DIR=$READTHEDOCS_VIRTUALENV_PATH/bin pipx install pdm==2.15.4
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc
post_build:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make mypy doc-coverage
os: ubuntu-22.04
tools:
python: '3.12'
Expand Down
6 changes: 3 additions & 3 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
{
"customType": "regex",
"datasourceTemplate": "pypi",
"description": "Match Python packages installed with pip, pipx and asdf",
"description": "Match Python packages installed with pip/pipx",
"fileMatch": [
"^Makefile$",
"^README\\.md$",
"^\\.devcontainer/Dockerfile$",
"^\\.github/workflows/.+\\.yml$",
Expand All @@ -20,14 +21,13 @@
"^includes/sample\\.jinja$",
"^template/.*\\.github.*/workflows/.+\\.yml(\\.jinja)?$",
"^template/.*\\.gitlab.*/workflows/.+\\.yml(\\.jinja)?$",
"^template/Makefile\\.jinja$",
"^template/\\.devcontainer/Dockerfile\\.jinja$",
"^template/\\.readthedocs\\.yaml$",
"^template/\\.renovaterc\\.json\\.jinja$",
"^template/docs/.+\\.md(\\.jinja)?$"
],
"matchStrings": [
"asdf global (?<depName>.*?) (?<currentValue>.*?)\n",
"asdf install (?<depName>.*?) (?<currentValue>.*?)\n",
"pip install.* (?<depName>.*?)==(?<currentValue>.*?)[\"\n]",
"pipx install (?<depName>.*?)==(?<currentValue>.*?)[;\n]"
]
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"toctree",
"typer",
"unshallow",
"viewcode"
"viewcode",
"VIRTUALENV"
],
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
Expand Down
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean deepclean install dev mypy ruff ruff-format toml-sort lint pre-commit test-run test build publish doc-autobuild doc-gen doc-mypy doc-coverage doc consistency
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format toml-sort lint pre-commit test-run test build publish doc-autobuild doc-gen doc-coverage doc consistency

########################################################################################
# Variables
Expand Down Expand Up @@ -51,13 +51,16 @@ dev:
pdm install
if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi

prerequisites:
pipx install --force mypy[reports]==1.10.0

########################################################################################
# Lint and pre-commit
########################################################################################

# Check lint with mypy.
mypy:
pdm run python -m mypy .
mypy --python-executable $(shell pdm info --python) --html-report $(PUBLIC_DIR)/reports/mypy .
msclock marked this conversation as resolved.
Show resolved Hide resolved

# Lint with ruff.
ruff:
Expand Down Expand Up @@ -119,17 +122,13 @@ doc-autobuild:
doc-gen:
pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR)

# Generate mypy reports.
doc-mypy:
pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy

# Generate html coverage reports with badge.
doc-coverage: test-run
pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage
pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges

# Generate all documentation with reports.
doc: doc-gen doc-mypy doc-coverage
doc: doc-gen mypy doc-coverage

########################################################################################
# Template
Expand Down
2 changes: 1 addition & 1 deletion docs/management/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The project template tracks the following dependencies:
1. [gitlabci](https://docs.renovatebot.com/modules/manager/gitlabci/): Containers in GitLab CI/CD.
1. [pre-commit](https://docs.renovatebot.com/modules/manager/pre-commit/): Pre-commit hooks.
1. Regex manager:
1. Python packages installed with pip, pipx and asdf, listed in the README, DevContainer Dockerfile, GitHub Actions, GitLab CI/CD, ReadTheDocs configuration, Renovate configuration and documentation.
1. Python packages installed with pip/pipx, listed in the README, Makefile, DevContainer Dockerfile, GitHub Actions, GitLab CI/CD, ReadTheDocs configuration, Renovate configuration and documentation.
1. Debian packages installed in the DevContainer Dockerfile.
1. PDM version specified in the `pdm-project/setup-pdm` GitHub action.
1. PDM version specified in the renovate constraints.
Expand Down
Loading