Skip to content

feat: add PEP 561 py.typed marker to support mypy type analysis (#563) - #817

Open
ShyamD2 wants to merge 2 commits into
aws:masterfrom
ShyamD2:feat/add-py-typed-marker
Open

ShyamD2 wants to merge 2 commits into
aws:masterfrom
ShyamD2:feat/add-py-typed-marker

Conversation

@ShyamD2

@ShyamD2 ShyamD2 commented Sep 8, 2026 •

Copy link
Copy Markdown

Issue #, if available:
Fixes #563
Description of changes:
Adds PEP 561 compliance so downstream projects using mypy can analyze aws_encryption_sdk without receiving error: Skipping analyzing "aws_encryption_sdk": module is installed, but missing library stubs or py.typed marker.

Summary of Changes:

  • Added src/aws_encryption_sdk/py.typed containing the partial marker per PEP 561.
  • Updated setup.py to include package_data={"aws_encryption_sdk": ["py.typed"]} so wheel packages bundle the marker.
  • Updated MANIFEST.in with include src/aws_encryption_sdk/py.typed for source distribution packaging.

Verification:

Tested with mypy analyzing public client initialization:

$ mypy -c "import aws_encryption_sdk; client = aws_encryption_sdk.EncryptionSDKClient()"
Success: no issues found in 1 source file

@ShyamD2
ShyamD2 requested a review from a team as a code owner September 8, 2026 18:10
@kessplas

Copy link
Copy Markdown
Contributor

Hello @ShyamD2 ,

Thanks for your contribution. As you point out, the ESDK for Python does not currently comply with PEP 561 or support Mypy in any meaningful way. However, we do not have any immediate plans to add new type hints, so it doesn't make sense to add these files to advertise typing information which is not actually present.

If you want to avoid the error, you can add this to your local configuration:

[[tool.mypy.overrides]]
module = "aws_encryption_sdk.*"
ignore_missing_imports = true

Alternatively, you propose in #563 to add .pyi stubs for the primary public API. This would be a more reasonable change. If you'd prefer this approach, please add .pyi stub files accordingly.

@ShyamD2

ShyamD2 commented Sep 17, 2026

Copy link
Copy Markdown
Author

Hello @kessplas,

Thanks for the feedback and guidance! That makes total sense—advertising typing via py.typed without actual type definitions doesn't provide real type safety downstream.

Per your suggestion, I have updated this PR with .pyi stub files covering the primary public API:

aws_encryption_sdk/init.pyi: Type definitions for EncryptionSDKClient, EncryptionSDKClientConfig, methods (encrypt, decrypt, and @overload definitions for stream), along with top-level re-exports.
identifiers.pyi & structures.pyi: Stubs for AlgorithmSuite / Algorithm, CommitmentPolicy, and MessageHeader.
streaming_client.pyi: Stubs for StreamEncryptor, StreamDecryptor, and config classes.
materials_managers/*.pyi & exceptions.pyi: Supporting public interfaces.
Updated setup.py and MANIFEST.in to ensure .pyi stubs and py.typed are bundled in both source distributions and wheels.
Verified with mypy resolving types correctly for client initialization, encryption, decryption, and streaming flows. Looking forward to your review!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add support for typing with mypy

2 participants