GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug: waiting_for is incorrectly type annotated · Issue #889 · testcontainers/testcontainers-python

Bug: waiting_for is incorrectly type annotated #889

New issue
Copy link
New issue
Copy link
Closed
Closed
Bug: waiting_for is incorrectly type annotated#889
Copy link

Description

@eteran
eteran
opened on Oct 2, 2025
Issue body actions

Describe the bug

waiting_for currently is annotated as returning "DockerContainer", but it really should be annotated as returning Self.
This is important because the incorrect annotation loses type information.

To Reproduce

Most type checkers will complain about assigning a DockerContainer to a variable of type MySqlContainer because of this

container: MySqlContainer = MySqlContainer("mysql:5.6", root_password="root").waiting_for(
            CompositeWaitStrategy(
                PortWaitStrategy(3306),
                LogMessageWaitStrategy("mysqld: ready for connections"),
            )
        )

Runtime environment

$ uname -a
Linux DESKTOP-971PGRM 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
$ python3 -V
Python 3.12.7
$ pip list | grep testcontainers
testcontainers                    4.13.1

Checkers such as Astral's ty and pyright complain.

Activity

  1. alexanderankin commented on Oct 2, 2025

    @alexanderankin
    alexanderankin
    on Oct 2, 2025
    Member
    More actions

    if you submit the PR I will merge, is it literally just this one line?

    diff --git a/core/testcontainers/core/container.py b/core/testcontainers/core/container.py
    index f0882a4..dcf576e 100644
    --- a/core/testcontainers/core/container.py
    +++ b/core/testcontainers/core/container.py
    @@ -169,7 +169,7 @@ class DockerContainer:
                 return self.with_kwargs(platform="linux/amd64")
             return self
     
    -    def waiting_for(self, strategy: WaitStrategy) -> "DockerContainer":
    +    def waiting_for(self, strategy: WaitStrategy) -> Self:
             """Set a wait strategy to be used after container start."""
             self._wait_strategy = strategy
             return self
  2. alexanderankin commented on Oct 2, 2025

    @alexanderankin
    alexanderankin
    on Oct 2, 2025
    Member
    More actions

    otherwise i need to get another maintainer involved usually takes longer

  3. eteran commented on Oct 2, 2025

    @eteran
    eteran
    on Oct 2, 2025
    ContributorAuthor
    More actions

    I think it is essentially just that one line 👍🏻 (perhaps and added import if needed).

    I'm about to head to bed, but I can make a PR for it tomorrow.

  4. eteran
    added a commit that references this issue on Oct 2, 2025

    Fix issue testcontainers#889 by changing the annotated return type of…

    a4ab35e
  5. eteran commented on Oct 2, 2025

    @eteran
    eteran
    on Oct 2, 2025
    ContributorAuthor
    More actions

    Actually, it was trivial and I test that it appeases pyright, so I've submitted a PR. Thanks for the quick response!

  6. alexanderankin
    added 2 commits that reference this issue on Oct 2, 2025

    fix: issue #889 by changing the annotated return type of `waiting_for…

    fe941b1

    chore(main): release testcontainers 4.13.2 (#891)

    5c1504c
  7. alexanderankin commented on Oct 7, 2025

    @alexanderankin
    alexanderankin
    on Oct 7, 2025
    Member
    More actions

    let me know if its still an issue on new release

  8. alexanderankin
    closed this as completedon Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.