-
Notifications
You must be signed in to change notification settings - Fork 103
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
Improve type annotations in core functions #850
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #850 +/- ##
==========================================
- Coverage 81.25% 81.14% -0.12%
==========================================
Files 24 24
Lines 1382 1421 +39
Branches 245 253 +8
==========================================
+ Hits 1123 1153 +30
- Misses 173 175 +2
- Partials 86 93 +7 ☔ View full report in Codecov by Sentry. |
This will improve typing when we accept user-provided arguments. Though, it mandates our users to annotate/cast the return values explicitly due to type variances. To completely resolve this issue, we have to introduce typed DTOs using pydantic or msgspec.
- `utils._AsyncCM` is completely removed and replaced with the intrinsic `contextlib._AsyncGeneratorContextManager`.
- If they are used in return values, the caller should perform extra type-narrowing or casting to pick a final type from union to avoid type check failures. - In a long term, it is better to declare typed DTOs.
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refs #847
from __future__ import annotations
.DockerContainer.log()
,DockerContainer.stats()
likeDockerImage.pull()
.JSONObject
,JSONList
,JSONValue
for API arguments, but not in the return values due to the type variance issue. In the future, it would be better to adopt explicitly typed DTOs.filters
arg used in many places.windows/amd64
platform weighs more than 2 GiB, while the alpine version is less than 20 MiB. This makes it to time out in high probability if pulled in pytest, as the pull takes more than 10 minutes. Unfortunately, there is no slim variants for thewindows/amd64
platform.docker pull
step explicitly before running pytest in CI, so that we can observe the pulling progress and decouple the timeout from pytest.docker load
anddocker save
simply takes a tooooo long time, so it's meaningless to improve the download speed by caching.Note
#861 has introduced explicit cancellation of
utils._AsyncCM
, but this PR removes it completely and replaces it with the intrinsic async context managers which provides better exception handling as "originally" expected.Checklist
CONTRIBUTORS.txt
changes
folder<issue_id>.<type>
for example (588.bug)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.