Repository navigation
Description
Problem or Motivation
docker-py 7.2.0 has no type hints, so every import of it in src carries # type: ignore[import-untyped]. Nine of the 51 markers under the src type: ignore ceiling are these imports (docker/engine.py, sandbox/host.py, commands/docker.py). Because the ceiling is at its value, new code cannot import docker-py's reference parser (docker.utils.parse_repository_tag, docker.auth.resolve_repository_name), so #1997 splits image references with its own 10 lines.
Proposed Solution & Architectural Design
- Add typeshed's
types-docker(7.2.0.20261006 matches docker 7.2.0) to the dev dependencies. - Measured on 2026-10-29 with the stubs installed: mypy reports the 9 docker-py ignores as unused, and 3 new errors in
src/devops_cli/docker/engine.py:- line 261:
create_api_error_from_http_exceptiontakes therequestsHTTPError, and the code passesException; - line 315:
DockerClientdoes not match theEngineClientProtocol of refactor(docker): DockerEngineService is the Docker engine seam, with an in-memory engine fake and its contract suite #2534 (5 member conflicts:api,containersand 3 more); - line 393: the stubs have no
docker.context.api.get_current_context_name.
- line 261:
- Fix the 3 errors (align the Protocols in
docker/sdk.pywith the stubs, narrow the exception type, and keep one ignore only where the stub lacks a name), delete the unused ignores, and lower thesrc type: ignoreceiling to the new count. - Move the reference split of
src/devops_cli/docker/registry.py(feat(argocd): a command reports when the devops Application's image digest differs from service:latest #1997) to docker-py's parser.
Target Subsystem
src/devops_cli/docker/, pyproject.toml, tests/test_architectural_invariants.py.
Existing Tool Considered
typeshed's types-docker stubs, maintained with typeshed. Nothing new is built; the change deletes ignores and the split of #1997.
Acceptance criteria
uv run mypy srcpasses withtypes-dockerinstalled, and thesrc type: ignoreceiling is lower than 51.- No
# type: ignore[import-untyped]names a docker-py module. tagged_imageindocker/registry.pyuses docker-py's parser, and its table tests still pass.
Proposed design
Problem statement
docker-py 7.2.0 ships no type hints, so nine imports in src carry # type: ignore[import-untyped] markers. The src type: ignore ceiling sits at 51, its value, so new code cannot import docker-py's reference parser. This blocks #1997 from using docker-py's parse_repository_tag and resolve_repository_name, forcing a 10-line hand-rolled split in registry.py. Adding typeshed's types-docker stubs removes the nine markers, frees ceiling budget, and lets registry.py use the typed parser.
Acceptance criteria
Requirement: mypy passes with types-docker
uv run mypy src SHALL pass with types-docker installed and no new errors in src/devops_cli/docker/engine.py.
Scenario: mypy run after adding types-docker
- WHEN types-docker is in the dev dependencies and the three errors in engine.py are fixed
- THEN uv run mypy src exits with code 0
Requirement: ceiling lowered
The src type: ignore ceiling in tests/test_architectural_invariants.py SHALL be lower than 51.
Scenario: ceiling value check
- WHEN the nine docker-py import-untyped markers are removed
- THEN DEFAULT_SUPPRESSION_CEILINGS['src type: ignore'] is 42
Requirement: no docker-py import-untyped markers
No # type: ignore[import-untyped] marker in src SHALL name a docker-py module.
Scenario: scan for docker-py import-untyped
- WHEN the codebase is scanned for type: ignore[import-untyped] comments
- THEN no comment names a docker, docker.utils, docker.errors, docker.constants, docker.transport, or docker.context module
Requirement: registry uses docker-py parser
tagged_image in src/devops_cli/docker/registry.py SHALL use docker-py's parse_repository_tag and resolve_repository_name to split a reference.
Scenario: tagged_image calls docker-py parser
- WHEN tagged_image is called with a valid reference such as ghcr.io/org/img:tag
- THEN the function calls docker.utils.parse_repository_tag and docker.auth.resolve_repository_name and returns the same TaggedImage as before
Requirement: registry table tests pass
The existing table tests of tagged_image SHALL pass after the parser change.
Scenario: table test run
- WHEN pytest runs the tagged_image table tests in tests/
- THEN all table test cases pass with the same expected TaggedImage values
Existing Tool Considered
typeshed's types-docker (7.2.0.20261006) covers the need of typing docker-py 7.2.0 imports. It lacks docker.context.api.get_current_context_name, which requires one remaining type: ignore marker.
Key questions
- Which open, maintained tool or library covers the need of typing docker-py imports?: typeshed's types-docker (7.2.0.20261006) provides type stubs for docker-py 7.2.0. It lacks docker.context.api.get_current_context_name. [sources: pyproject.toml, src/devops_cli/docker/engine.py:393]
- How to fix the mypy error at engine.py line 261 where create_api_error_from_http_exception expects requests.HTTPError but the code passes Exception?: Narrow the except clause from Exception to requests.HTTPError, matching the stub's signature. (best practice) [sources: src/devops_cli/docker/engine.py:261]
- Chosen: Narrow except to requests.HTTPError. The stub types create_api_error_from_http_exception with a requests.HTTPError parameter. Narrowing the catch matches the stub and removes the need for a type ignore.
- Rejected: Keep except Exception and add a type ignore. Rejected because it adds a marker to the ceiling instead of removing one.
- How to fix the mypy error at engine.py line 315 where DockerClient does not match the EngineClient Protocol (5 member conflicts)?: Align the Protocols in src/devops_cli/docker/sdk.py with the types-docker stubs so that DockerClient satisfies EngineClient. (best practice) [sources: src/devops_cli/docker/engine.py:315, src/devops_cli/docker/sdk.py]
- Chosen: Align Protocols in sdk.py with the stubs. The body states this approach. It removes the 5 conflicts at the source and keeps the Protocol as the seam for fakes.
- Rejected: Add type ignores for the 5 conflicts. Rejected because it adds five markers to the ceiling instead of removing nine.
- How to handle the mypy error at engine.py line 393 where the stubs have no docker.context.api.get_current_context_name?: Keep one # type: ignore[import-untyped] marker on that import, since the stub genuinely lacks the name. (best practice) [sources: src/devops_cli/docker/engine.py:393]
- Chosen: Keep one type ignore for the missing name. The body states this approach. The stub lacks the name, so a single targeted marker is the correct suppression.
- Rejected: Remove the call and use an alternative. Rejected because get_current_context_name is the only way to read the current context name from docker-py's config, and no alternative exists in the stubs.
- What is the new src type: ignore ceiling after removing the nine docker-py markers?: 42, which is 51 minus the nine removed markers. [sources: tests/test_architectural_invariants.py, src/devops_cli/docker/engine.py]
- Which parser should tagged_image in registry.py use to split a reference?: docker-py's parse_repository_tag and resolve_repository_name, now typed by types-docker. (best practice) [sources: src/devops_cli/docker/registry.py, openspec/changes/archive/2026-10-29-1997-argo-image-pin-drift/proposal.md]
- Chosen: Use docker-py's parse_repository_tag and resolve_repository_name. The body states this approach. With types-docker installed, the import is typed and adds no marker. It replaces the 10-line hand-rolled split.
- Rejected: Keep the 10-line hand-rolled split. Rejected because the whole purpose of this item is to use the typed parser and free ceiling budget.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Oct 29, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
The change adds type stubs, fixes type errors, and removes ignore markers without altering runtime behaviour.It unblocks new docker-py imports at the ceiling but does not fix a user-facing defect.It raises type safety and unblocks developer work but has no direct end-user effect.It requires adding a dependency, fixing 3 type errors, deleting 9 markers, lowering a ceiling, and refactoring one function.Both touch pyproject.toml dependencies, but 1120 ensures every imported package is declared while this adds type stubs and cleans up ignore markers.devops-cli-service commentedon Oct 30, 2026
Status set to Ready at 07fb4c2 (see proposed design in issue body).
devops-cli-service commentedon Nov 1, 2026
Staged: branch
build/2603-type-docker-py-with-typeshed-s, draft pull request #3071. The pull request plans the item and closes no issue.The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:
These paths of the plan are no file on the default branch, and no group creates them:
tests/test_architectural_invariants.py. A person checks that the plan names them right.docs(openspec): fix plan #2603 real ceiling, no Protocol alignment, k…
docs(openspec): fix plan #2610 history, task shape, overlap
docs(openspec): plan #2610 use tag_digest HEAD for image pins (#3096)
docs(openspec): plan #2603 Type docker-py with types-docker (#3071)
[-]build(deps): type docker-py with typeshed's types-docker, and drop its type: ignore markers[/-][+]build(deps): Type docker-py with types-docker[/+]dan-petty commentedon Nov 6, 2026
The job shortened the title of this item. The summary had 78 characters, and the limit is 60. The type and the scope stay.
build(deps): type docker-py with typeshed's types-docker, and drop its type: ignore markersbuild(deps): Type docker-py with types-docker