Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: type hint miss match on get_exposed_port #712

Open
MatheusAbdias opened this issue Oct 5, 2024 · 0 comments
Open

Bug: type hint miss match on get_exposed_port #712

MatheusAbdias opened this issue Oct 5, 2024 · 0 comments

Comments

@MatheusAbdias
Copy link

Describe the bug

A clear and concise description of what the bug is. What did you expect to happen? What happened instead?
Method get_exposed_port type miss match:

    @wait_container_is_ready()
    def get_exposed_port(self, port: int) -> str:
        mapped_port = self.get_docker_client().port(self._container.id, port)
        if inside_container():
            gateway_ip = self.get_docker_client().gateway_ip(self._container.id)
            host = self.get_docker_client().host()

            if gateway_ip == host:
                return port
        return mapped_port

mapped_port is int type and port is int type, so this method should return an int.

To Reproduce

Provide a self-contained code snippet that illustrates the bug or unexpected behavior. Ideally, send a Pull Request to illustrate with a test that illustrates the problem.

# settings.py
class Settings(BaseSettings):
    POSTGRES_PORT: int = 5432

# conftest.py
@pytest.fixture(scope="module", autouse=True)
def setup(request):
    postgres.start()

    def remove_container():
        postgres.stop()

    request.addfinalizer(remove_container)
    settings.POSTGRES_PORT = postgres.get_exposed_port(5432) # pylance error type miss match 

Image

Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.

python: 3.12
testcontainers: 4.8.1
docker: 27.3.1

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

No branches or pull requests

1 participant