Skip to content

Bug: waiting_for is incorrectly type annotated #889

Description

@eteran

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

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