rdozier-work / docker-stubs

type stubs for the Docker Python SDK
8 stars 2 forks source link

Current issues #2

Closed Tatsh closed 6 months ago

Tatsh commented 6 months ago

This is only a subset of issues because it is the part of the library I am currently using. Perhaps it's a good starting point if you are not going to type everything yet. It covers basic use cases like building a container, running one, stopping it, etc.

Maybe some of these are resolved with #1

rdozier-work commented 6 months ago

I closed #1 because there were too many apparent errors. Let me take a look at these and get back to you

rdozier-work commented 6 months ago

models.containers.Container.stop() is untyped

There is a return statement in the method but the method it calls (stop() in ContainerApiMixIn) is a void method

models.containers.Container.exec_run(): cmd argument should accept tuple[str, ...] as well

True, I can change it to support Iterable[str] honestly that would be best IMO

models.containers.Container.image should be Image not str

Good catch!

api.client.APIClient.build() should accept kwarg fileobj which is type BytesIO

The base method is (IIRC) in BuildApiMixIn. I have that kwarg as Incomplete | None so I'll change it to BytesIO | None. Should that work?

docker.utils.json_stream.json_stream() is untyped. It should accept the return value from api.client.APIClient.build()

I made this ResponseResult type alias for Union[Json, bytes, AnyStr] since I believe APIClient._result() can return a stream of any of those, so I believe this should be Generator[ResponseResult, None, None] but I would be surprised if there isn't a more elegant way to do this.

docker.from_env() is missing kwargs (max_pool_size: int, timeout: int, use_ssh_client: bool)

This is because the source code doesn't call those out specifically. I agree that these would be good to add/support but I think that is lower on the priority list

models.containers.ContainerCollection.run() is untyped

Good catch! I think that one confused me so much that I skipped it and forgot to come back.

Feel free to make a PR to address some/all of these, I'm not sure when I'll have time to get to it... The SDK itself is open source, so if you'd be interested in helping me make a PR to just add type annotations to the source code let me know!