From 003f5fc6e4eacb8de8be9e7990bc2c75554077a0 Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Wed, 2 Jul 2025 19:59:04 +0000 Subject: [PATCH 1/7] Fix a mypy issue in config --- core/testcontainers/core/config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/testcontainers/core/config.py b/core/testcontainers/core/config.py index 461bfe59..e521bd4d 100644 --- a/core/testcontainers/core/config.py +++ b/core/testcontainers/core/config.py @@ -7,7 +7,7 @@ from os import environ from os.path import exists from pathlib import Path -from typing import Final, Optional, Union, cast +from typing import Final, Optional, Union import docker @@ -39,7 +39,6 @@ def get_docker_socket() -> str: try: client = docker.from_env() socket_path = client.api.get_adapter(client.api.base_url).socket_path - socket_path = cast("str", socket_path) # return the normalized path as string return str(Path(socket_path).absolute()) except Exception: From fd954547a54bccefc158f2f0303ddc08e15386fc Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Wed, 2 Jul 2025 20:09:33 +0000 Subject: [PATCH 2/7] add mypy to ci-lint --- .github/workflows/ci-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 18633587..6b352df9 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -26,3 +26,4 @@ jobs: poetry run pre-commit run end-of-file-fixer poetry run pre-commit run ruff poetry run pre-commit run ruff-format + poetry run pre-commit run mypy From 681ce3d5953e58e9946549e6c4332699964bb4d9 Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Thu, 3 Jul 2025 09:09:05 +0000 Subject: [PATCH 3/7] Revert "add mypy to ci-lint" This reverts commit fd954547a54bccefc158f2f0303ddc08e15386fc. --- .github/workflows/ci-lint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 6b352df9..18633587 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -26,4 +26,3 @@ jobs: poetry run pre-commit run end-of-file-fixer poetry run pre-commit run ruff poetry run pre-commit run ruff-format - poetry run pre-commit run mypy From e31efa23778c67186013f83055864d91631c5c1a Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Thu, 3 Jul 2025 09:15:02 +0000 Subject: [PATCH 4/7] add mypy + report fix report more report fixes fix pipeline fix2 --- .github/workflows/ci-lint.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 18633587..9f880243 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -26,3 +26,14 @@ jobs: poetry run pre-commit run end-of-file-fixer poetry run pre-commit run ruff poetry run pre-commit run ruff-format + - name: Execute mypy + run: | + poetry run mypy --config-file pyproject.toml core > mypy.log 2>&1 + if [ -s mypy.log ]; then + cat mypy.log + echo "Mypy issues found. Generating report..."; + cat mypy.log | poetry run python scripts/mypy_report.py + exit 1 + else + echo "No mypy issues found."; + fi From 4a5b122ec05815115529e7b33444d9ce57a761bd Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Thu, 3 Jul 2025 11:13:46 +0000 Subject: [PATCH 5/7] improve flow fix --- .github/workflows/ci-lint.yml | 12 +++--------- Makefile | 5 ++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml index 9f880243..3d9d1701 100644 --- a/.github/workflows/ci-lint.yml +++ b/.github/workflows/ci-lint.yml @@ -20,6 +20,7 @@ jobs: - name: Install Python dependencies run: poetry install --no-interaction - name: Execute pre-commit handler + continue-on-error: true run: | poetry run pre-commit run check-toml poetry run pre-commit run trailing-whitespace @@ -28,12 +29,5 @@ jobs: poetry run pre-commit run ruff-format - name: Execute mypy run: | - poetry run mypy --config-file pyproject.toml core > mypy.log 2>&1 - if [ -s mypy.log ]; then - cat mypy.log - echo "Mypy issues found. Generating report..."; - cat mypy.log | poetry run python scripts/mypy_report.py - exit 1 - else - echo "No mypy issues found."; - fi + make mypy-core-report + make mypy-core diff --git a/Makefile b/Makefile index 855a9d9c..1e1dde60 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,10 @@ coverage: ## Target to combine and report coverage. lint: ## Lint all files in the project, which we also run in pre-commit poetry run pre-commit run -a -mypy-core-report: +mypy-core: ## Run mypy on the core package + poetry run mypy --config-file pyproject.toml core + +mypy-core-report: ## Generate a report for mypy on the core package poetry run mypy --config-file pyproject.toml core | poetry run python scripts/mypy_report.py docs: ## Build the docs for the project From dfaa4304b994784812c17632795548d7ea091507 Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Thu, 3 Jul 2025 09:15:42 +0000 Subject: [PATCH 6/7] DEBUG: added mypy issue --- core/testcontainers/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/testcontainers/core/config.py b/core/testcontainers/core/config.py index e521bd4d..cc31f811 100644 --- a/core/testcontainers/core/config.py +++ b/core/testcontainers/core/config.py @@ -18,7 +18,7 @@ class ConnectionMode(Enum): docker_host = "docker_host" @property - def use_mapped_port(self) -> bool: + def use_mapped_port(self) -> str: """ Return True if mapped ports should be used for this connection mode. From 6210229c164dcd4acc867bc039cb221f7b36f11a Mon Sep 17 00:00:00 2001 From: Roy Moore Date: Thu, 3 Jul 2025 12:01:34 +0000 Subject: [PATCH 7/7] Revert "DEBUG: added mypy issue" This reverts commit dfaa4304b994784812c17632795548d7ea091507. --- core/testcontainers/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/testcontainers/core/config.py b/core/testcontainers/core/config.py index cc31f811..e521bd4d 100644 --- a/core/testcontainers/core/config.py +++ b/core/testcontainers/core/config.py @@ -18,7 +18,7 @@ class ConnectionMode(Enum): docker_host = "docker_host" @property - def use_mapped_port(self) -> str: + def use_mapped_port(self) -> bool: """ Return True if mapped ports should be used for this connection mode.