Skip to content

fix(sdk-python): remove mypy-boto3-ssm runtime dependency#165

Merged
macalbert merged 7 commits intomainfrom
fix/sdk-python-remove-mypy-boto3-runtime-dep
Apr 17, 2026
Merged

fix(sdk-python): remove mypy-boto3-ssm runtime dependency#165
macalbert merged 7 commits intomainfrom
fix/sdk-python-remove-mypy-boto3-runtime-dep

Conversation

@macalbert
Copy link
Copy Markdown
Owner

@macalbert macalbert commented Apr 17, 2026

Summary

AwsSsmSecretProvider imported mypy_boto3_ssm.SSMClient at runtime, but the
package is a dev-only type stub. Consumers installing envilder from PyPI got
ModuleNotFoundError. This PR fixes the import, bumps to 0.3.1, and adds SDK
usage examples for Python and .NET.

Changes

fix(sdk-python)

  • Replace mypy_boto3_ssm.SSMClient with botocore.client.BaseClient in
    AwsSsmSecretProviderbotocore is already bundled with boto3
  • Add # type: ignore[attr-defined] on get_parameter call (dynamic method)
  • Bump version 0.3.00.3.1

fix(sdk)

  • Remove stale AWSSDK.SimpleSystemsManagement package reference from .NET examples

docs(sdk)

  • Add example/sdk/python/ — 4 self-contained scripts using PEP 723 inline
    metadata (uv run 1_load.py, no setup required)
  • Add example/sdk/dotnet/ — 3 file-based .NET 10 apps (dotnet run 1_resolve.cs)
  • Per-stack READMEs with prerequisites and run instructions

docs(sdk-python)

  • Add 0.3.1 changelog entry in docs/changelogs/sdk-python.md

Testing

  • make check-sdk-python passes (black, isort, mypy)
  • make test-sdk-python — 54/54 tests pass
  • Consumer smoke test: uv run 1_load.py resolves secrets successfully
  • All 4 Python examples and 3 .NET examples run without errors

Replace mypy_boto3_ssm.SSMClient with botocore.client.BaseClient in

AwsSsmSecretProvider. The mypy_boto3_ssm package is a dev-only type

stub that was imported at runtime, causing ModuleNotFoundError for

consumers installing envilder from PyPI without dev extras.

Bump version 0.3.0 -> 0.3.1.
Minimal per-approach examples for Python SDK (load, resolve, fluent,

env routing) and .NET SDK (resolve, inject, configuration) as

file-based apps.
Copilot AI review requested due to automatic review settings April 17, 2026 13:33
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@macalbert has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 26 minutes and 16 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 26 minutes and 16 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 35ac405a-96e6-4ed9-b0fd-461ab95900ee

📥 Commits

Reviewing files that changed from the base of the PR and between 73e9177 and e7748c1.

⛔ Files ignored due to path filters (8)
  • example/sdk/dotnet/1_resolve.cs is excluded by none and included by none
  • example/sdk/dotnet/2_inject.cs is excluded by none and included by none
  • example/sdk/dotnet/3_configuration.cs is excluded by none and included by none
  • example/sdk/python/1_load.py is excluded by none and included by none
  • example/sdk/python/2_resolve.py is excluded by none and included by none
  • example/sdk/python/3_fluent.py is excluded by none and included by none
  • example/sdk/python/4_env_routing.py is excluded by none and included by none
  • example/sdk/python/README.md is excluded by none and included by none
📒 Files selected for processing (2)
  • docs/changelogs/sdk-python.md
  • src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py

Walkthrough

The pull request updates the Python SDK by relaxing the type annotation for the AWS SSM secret provider to accept a generic botocore.client.BaseClient instead of a typed SSM-specific client, and bumps the package version to 0.3.1.

Changes

Cohort / File(s) Summary
Type Annotation Update
src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py
Changed ssm_client parameter type from SSMClient to botocore.client.BaseClient with type-ignore comment for get_parameter attribute access.
Version Bump
src/sdks/python/pyproject.toml
Updated package version from 0.3.0 to 0.3.1.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing the runtime dependency on mypy-boto3-ssm from the SDK.
Description check ✅ Passed The description includes Problem, Solution, and Changes sections explaining the issue, fix, and validation. The template requires What/Issues/Type/Checklist but the author provided a more detailed custom format with comprehensive context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sdk-python-remove-mypy-boto3-runtime-dep

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@macalbert macalbert self-assigned this Apr 17, 2026
@macalbert macalbert added the bug Something isn't working label Apr 17, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py (1)

3-3: Consider preserving static typing via TYPE_CHECKING.

Switching the runtime import to botocore.client.BaseClient correctly fixes the ModuleNotFoundError for consumers without dev extras. However, you lose the precise typing of SSMClient and now need # type: ignore[attr-defined] on every SSM call.

An alternative keeps both runtime safety and strict typing: import SSMClient only under TYPE_CHECKING (since boto3-stubs[ssm] is already a dev dep per pyproject.toml), and annotate the parameter with a string/forward reference.

♻️ Proposed refactor
 from __future__ import annotations

-from botocore.client import BaseClient
+from typing import TYPE_CHECKING
+
 from botocore.exceptions import ClientError

 from envilder.domain.ports.secret_provider import ISecretProvider

+if TYPE_CHECKING:
+    from mypy_boto3_ssm import SSMClient
+

 class AwsSsmSecretProvider(ISecretProvider):
-    def __init__(self, ssm_client: BaseClient) -> None:
+    def __init__(self, ssm_client: "SSMClient") -> None:
         if ssm_client is None:
             raise ValueError("ssm_client cannot be None")
         self._ssm_client = ssm_client
@@
         try:
-            response = self._ssm_client.get_parameter(  # type: ignore[attr-defined]
+            response = self._ssm_client.get_parameter(
                 Name=name, WithDecryption=True
             )

Because of from __future__ import annotations, the annotation never evaluates at runtime, so mypy_boto3_ssm stays a pure dev-only dependency and strict mypy retains full method signatures (no attr-defined suppression needed).

Also applies to: 10-10, 20-22

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py` at
line 3, Replace the direct runtime import of botocore's BaseClient with a
pattern that preserves strict typing: keep the existing runtime import of
BaseClient, add a conditional import of SSMClient inside an if TYPE_CHECKING
block (from mypy_boto3_ssm.client import SSMClient), and change any
parameter/type annotations that currently use BaseClient to use a
forward-reference/string annotation "SSMClient" (or annotate using SSMClient
under TYPE_CHECKING) so callers avoid needing # type: ignore[attr-defined] while
runtime remains safe; reference symbols: BaseClient, SSMClient, TYPE_CHECKING
and update the function/method signatures that accept the SSM client
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py`:
- Line 3: Replace the direct runtime import of botocore's BaseClient with a
pattern that preserves strict typing: keep the existing runtime import of
BaseClient, add a conditional import of SSMClient inside an if TYPE_CHECKING
block (from mypy_boto3_ssm.client import SSMClient), and change any
parameter/type annotations that currently use BaseClient to use a
forward-reference/string annotation "SSMClient" (or annotate using SSMClient
under TYPE_CHECKING) so callers avoid needing # type: ignore[attr-defined] while
runtime remains safe; reference symbols: BaseClient, SSMClient, TYPE_CHECKING
and update the function/method signatures that accept the SSM client
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 39e7437b-2a89-4b90-aaa4-35b62cbe6edf

📥 Commits

Reviewing files that changed from the base of the PR and between a89c02d and 73e9177.

⛔ Files ignored due to path filters (12)
  • example/sdk/dotnet/1_resolve.cs is excluded by none and included by none
  • example/sdk/dotnet/2_inject.cs is excluded by none and included by none
  • example/sdk/dotnet/3_configuration.cs is excluded by none and included by none
  • example/sdk/dotnet/README.md is excluded by none and included by none
  • example/sdk/python/1_load.py is excluded by none and included by none
  • example/sdk/python/2_resolve.py is excluded by none and included by none
  • example/sdk/python/3_fluent.py is excluded by none and included by none
  • example/sdk/python/4_env_routing.py is excluded by none and included by none
  • example/sdk/python/README.md is excluded by none and included by none
  • example/sdk/python/pyproject.toml is excluded by none and included by none
  • example/sdk/python/uv.lock is excluded by !**/*.lock and included by none
  • src/sdks/python/uv.lock is excluded by !**/*.lock and included by src/**
📒 Files selected for processing (2)
  • src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py
  • src/sdks/python/pyproject.toml

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

gemini-code-assist[bot]

This comment was marked as resolved.

Simple example scripts don't need a full Python project. A one-line

requirements.txt is sufficient.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the Python SDK’s runtime import of a dev-only type-stubs package (mypy_boto3_ssm) by switching the AWS SSM client annotation to a runtime-available type (botocore.client.BaseClient). Also bumps the Python SDK patch version and adds runnable SDK examples for Python and .NET.

Changes:

  • Replace mypy_boto3_ssm.SSMClient runtime import with botocore.client.BaseClient in the Python AWS SSM provider.
  • Bump Python SDK version 0.3.00.3.1 (and update the SDK lockfile).
  • Add new example projects under example/sdk/python/ and example/sdk/dotnet/.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/sdks/python/envilder/infrastructure/aws/aws_ssm_secret_provider.py Removes runtime dependency on mypy_boto3_ssm by using BaseClient typing and a targeted mypy ignore.
src/sdks/python/pyproject.toml Patch version bump to 0.3.1.
src/sdks/python/uv.lock Lockfile updated for the SDK version bump.
example/sdk/python/pyproject.toml Adds a minimal uv-managed Python example project referencing the SDK.
example/sdk/python/uv.lock Adds a lockfile for the Python examples project.
example/sdk/python/README.md Documents how to run the Python examples.
example/sdk/python/1_load.py Example: load + inject into os.environ.
example/sdk/python/2_resolve.py Example: resolve without injecting.
example/sdk/python/3_fluent.py Example: fluent overrides (provider/profile).
example/sdk/python/4_env_routing.py Example: environment-based map routing.
example/sdk/dotnet/README.md Documents how to run the .NET examples.
example/sdk/dotnet/1_resolve.cs Example: resolve secrets and print.
example/sdk/dotnet/2_inject.cs Example: resolve + inject into environment.
example/sdk/dotnet/3_configuration.cs Example: use Envilder as an IConfiguration source.

Each script declares its own dependencies via inline metadata.

Removes requirements.txt — uv run handles everything.
Copilot AI review requested due to automatic review settings April 17, 2026 13:47

This comment was marked as resolved.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment thread docs/changelogs/sdk-python.md
@macalbert macalbert merged commit fa2b064 into main Apr 17, 2026
12 checks passed
@macalbert macalbert deleted the fix/sdk-python-remove-mypy-boto3-runtime-dep branch April 17, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants