-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[docker-py] Add some missing types #15084
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
base: main
Are you sure you want to change the base?
Conversation
- `Container` - `ContainerCollection` - `ExecApiMixin`
This comment has been minimized.
This comment has been minimized.
stubs/docker/docker/api/exec_api.pyi
Outdated
| ): ... | ||
| self, | ||
| exec_id: str, | ||
| detach: Literal[True] = ..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wouldn't work, since it would also match if detach is left out (meaning it's False):
| detach: Literal[True] = ..., | |
| detach: Literal[True], |
| @overload | ||
| def exec_start( | ||
| self, | ||
| exec_id: str, | ||
| detach: Literal[False] = False, | ||
| tty: bool = False, | ||
| stream: bool = False, | ||
| socket: Literal[True] = ..., | ||
| demux: bool = False, | ||
| ) -> SocketIO | _BufferedReaderStream | SSHSocket: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same is true for the socket argument here. Unfortunately, we can't just remove the default as that would cause a syntax error. So we can to split this overload into two:
| @overload | |
| def exec_start( | |
| self, | |
| exec_id: str, | |
| detach: Literal[False] = False, | |
| tty: bool = False, | |
| stream: bool = False, | |
| socket: Literal[True] = ..., | |
| demux: bool = False, | |
| ) -> SocketIO | _BufferedReaderStream | SSHSocket: ... | |
| @overload | |
| def exec_start( | |
| self, | |
| exec_id: str, | |
| detach: Literal[False], | |
| tty: bool, | |
| stream: bool, | |
| socket: Literal[True], | |
| demux: bool = False, | |
| ) -> SocketIO | _BufferedReaderStream | SSHSocket: ... | |
| @overload | |
| def exec_start( | |
| self, | |
| exec_id: str, | |
| detach: Literal[False] = False, | |
| tty: bool = False, | |
| stream: bool = False, | |
| *, | |
| socket: Literal[True], | |
| demux: bool = False, | |
| ) -> SocketIO | _BufferedReaderStream | SSHSocket: ... |
The same for the other overloads using a ... default below. I won't be pretty.
|
Thank you for your hints @srittau. I think that overloads work properly now |
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Add missing types for the methods of the following classes:
ContainerContainerCollectionExecApiMixinReferences: