Skip to content

Conversation

@andres-ito-traversal
Copy link
Contributor

@andres-ito-traversal andres-ito-traversal commented Nov 12, 2025

Summary

Adds py.typed marker files to all testcontainers packages to comply with PEP 561 and enable type checking support.

Motivation

Without py.typed markers, type checkers like Pyright and mypy report "Stub file not found" errors when importing testcontainers modules, even though the code has inline type annotations.

Changes

  • Added py.typed marker to core/testcontainers/
  • Added py.typed markers to all module packages under modules/*/testcontainers/
  • Updated pyproject.toml to ensure py.typed files are included in distributions

Testing

Verified that type checkers no longer report missing stub file errors:

pyright -c "from testcontainers.postgres import PostgresContainer"
# 0 errors, 0 warnings, 0 informations

Impact

  • Enables proper type checking for projects using testcontainers
  • No breaking changes or runtime behavior modifications
  • Aligns with Python packaging best practices (PEP 561)

Github Issue=#305

@andres-ito-traversal andres-ito-traversal changed the title Add PEP 561 py.typed markers for type checker support fix: add PEP 561 py.typed markers for type checker support Nov 12, 2025
@andres-ito-traversal
Copy link
Contributor Author

@rnorth Apologies richard for the random tag, but do you have any idea how authors will get notified of this PR? It's my first time contributing to this open-source library

  Add py.typed marker files to core and all module packages to indicate
  type information is available. This enables type checkers like Pyright
  and mypy to recognize and validate type hints in testcontainers packages.

  Resolves "Stub file not found" errors when running type checkers on
  code that imports testcontainers modules.
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.78%. Comparing base (5853d32) to head (468ede5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #918   +/-   ##
=======================================
  Coverage   79.78%   79.78%           
=======================================
  Files          14       14           
  Lines        1182     1182           
  Branches      184      184           
=======================================
  Hits          943      943           
  Misses        197      197           
  Partials       42       42           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant