-
-
Notifications
You must be signed in to change notification settings - Fork 387
feat: add type hinting to s3.open() and main open()
#885
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: develop
Are you sure you want to change the base?
Conversation
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.
CI should really get upgraded and have ruff for checking and pyright for type validations
I would love an astral stack upgrade! They also built a type checker that I expect will supercede mypy/pyright over time: https://github.com/astral-sh/ty
Overall it would be great to have some CI to cover this PR before merging.
Big bonus would be to differentiate r/w/a return types (see docstring I mentioned in the issue, although I don't know a project that has implemented this properly).
| encoding: None = ..., | ||
| errors: None = ..., | ||
| newline: None = ..., | ||
| closefd: bool = ..., |
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.
can't all these be omitted? ie the overloads only contain uri and mode? also the type hints here (None) are differing from below
| compression: str = ..., | ||
| transport_params: dict[str, Any] | None = ..., | ||
| ) -> TextIO: ... | ||
| @overload |
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.
2 newlines?
| errors: str | None = None, | ||
| newline: str | None = None, | ||
| closefd: bool = True, | ||
| opener: object | None = None, |
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.
closefd and opener are completely ignored, not even propagated to _shortcut_open
| client: object | None = None, | ||
| client_kwargs: dict | None = None, | ||
| writebuffer: IO[bytes] | None = None, | ||
| ) -> BinaryIO: |
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.
why IO[bytes] and not BinaryIO for writebuffer?
|
first step towards |
Motivation
Related to #518. Not a complete fix, but makes some progress.
Tests
CI should really get upgraded and have
rufffor checking andpyrightfor type validations.