Skip to content

Commit ef65bd1

Browse files
authored
fix: Enable mypy in the CI (#842)
1. leftovers from a previous mypy refactor ```python core/testcontainers/core/config.py:42: error: Redundant cast to "str" [redundant-cast] socket_path = cast("str", socket_path) ``` Post fix: ```bash #poetry run mypy --config-file pyproject.toml core Success: no issues found in 36 source files ``` 2. add mypy check to the CI under lint, also create a simple report if something is wrong.
1 parent 1532df5 commit ef65bd1

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.github/workflows/ci-lint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ jobs:
2020
- name: Install Python dependencies
2121
run: poetry install --no-interaction
2222
- name: Execute pre-commit handler
23+
continue-on-error: true
2324
run: |
2425
poetry run pre-commit run check-toml
2526
poetry run pre-commit run trailing-whitespace
2627
poetry run pre-commit run end-of-file-fixer
2728
poetry run pre-commit run ruff
2829
poetry run pre-commit run ruff-format
30+
- name: Execute mypy
31+
run: |
32+
make mypy-core-report
33+
make mypy-core

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ coverage: ## Target to combine and report coverage.
3131
lint: ## Lint all files in the project, which we also run in pre-commit
3232
poetry run pre-commit run -a
3333

34-
mypy-core-report:
34+
mypy-core: ## Run mypy on the core package
35+
poetry run mypy --config-file pyproject.toml core
36+
37+
mypy-core-report: ## Generate a report for mypy on the core package
3538
poetry run mypy --config-file pyproject.toml core | poetry run python scripts/mypy_report.py
3639

3740
docs: ## Build the docs for the project

core/testcontainers/core/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from os import environ
88
from os.path import exists
99
from pathlib import Path
10-
from typing import Final, Optional, Union, cast
10+
from typing import Final, Optional, Union
1111

1212
import docker
1313

@@ -39,7 +39,6 @@ def get_docker_socket() -> str:
3939
try:
4040
client = docker.from_env()
4141
socket_path = client.api.get_adapter(client.api.base_url).socket_path
42-
socket_path = cast("str", socket_path)
4342
# return the normalized path as string
4443
return str(Path(socket_path).absolute())
4544
except Exception:

0 commit comments

Comments
 (0)