-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Update deprecated type annotations produced by AWS scaffold tool #13347
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
Conversation
|
@thrau I'd appreciate a read on how/whether to proceed with this, see questions above. |
|
This makes a lot of sense to me! The APIs are not used in a context where we would need compatibility with older python versions. This makes the APIs more consistent with our other code styles, so 👍 @alexrashed anything to add? |
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 7m 48s ⏱️ Results for commit df9a078. ♻️ This comment has been updated with latest results. |
Test Results - Preflight, Unit22 259 tests - 23 20 507 ✅ - 23 16m 12s ⏱️ -23s Results for commit 47cf9af. ± Comparison against base commit 447dd8e. This pull request removes 23 tests.♻️ This comment has been updated with latest results. |
|
But would it also make sense to run through all the APIs and regenerate them? Or is there a risk I'm not seeing? It doesn't seem like things are often regenerated. |
That would definitely make sense! And in fact, they are regenerated every week by our "ASF Update Action", which results in PRs like this: #13283 |
d1e6ce7 to
3b7a3a8
Compare
|
Thand @alexrashed. Yeah, I'm looking at the compile errors. |
3b7a3a8 to
c41dd71
Compare
|
Fixed now, and I also regenerated the module for S3, which was involved in the failure above. Looking at the failures, there are interesting cases in the generated code that were possibly not correct even before this change. For example, in the s3 API: Location = str
...
class PostResponse(TypedDict, total=False):
StatusCode: None | GetObjectResponseStatusCode
Location: None | Location
LocationHeader: None | Location # Here pyright sees a reference to PostResponse.Location, not the top-level Location type alias
Bucket: None | BucketName
Key: None | ObjectKey
Expiration: None | Expiration
ETag: None | ETag
ETagHeader: None | ETag
ChecksumCRC32: None | ChecksumCRC32
ChecksumCRC32C: None | ChecksumCRC32C
ChecksumCRC64NVME: None | ChecksumCRC64NVME
ChecksumSHA1: None | ChecksumSHA1
ChecksumSHA256: None | ChecksumSHA256
ChecksumType: None | ChecksumType |
|
If this looks acceptable, I expect the best plan would be to take out the generated changes from this commit, and merge only the scaffold generator changes, so that the next auto-update would cleanly update everything together. |
alexrashed
left a comment
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 is looking great! I guess the failing tests are not associated to the changes here, and will most likely be fixed by a rebase.
Concerning the approach, I don't have a strong opinion, but basically we can (a) either combine the update with the changes here maybe in separate commits (+ create a separate PR in our downstream repo to update the generated code there as well), or (b) we just merge the changes to the code generation and let the automation update all the code.
In guess (a) is a bit cleaner because then the API changes aren't mixed with the updated code generation and we have an isolated CI execution for the changes in the generated code, but (b) is a bit simpler to execute on.
I'd just leave that to you! 😃
As of Python 3.9, common type annotations have changed, and the old ones (e.g. List, Optional, Union) generate deprecation warnings in some tools (pyright in my case). This change updates the generation of scaffolded types to use the new names, and also adds default values in some cases, where further warnings were previously reported.
c41dd71 to
47cf9af
Compare
|
I've fixed that nit, and separated the change into two commits: one for the generator change, and the other for the API regeneration. If the tests run through fine, I'll drop the latter and we can just merge the former, waiting for the weekly job to cleanly regenerate everything. |
|
Tests are good. I'll remove the generated API update commit, and mark this ready for review. |
47cf9af to
df9a078
Compare
alexrashed
left a comment
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.
😛
|
Awesome 🎉 We even might simplify some |
|
Yes, it looks like all those exclusion codes relate to annotations, so they shouldn't be necessary now. |
As of #13347, the type annotations in those modules are modern and will not upset ruff.
|
Submitted a fix in #13355. |
As of #13347, the type annotations in those modules are modern and will not upset ruff.
Motivation
As of Python 3.9, common type annotations have changed, and the old ones (e.g. List, Optional, Union) generate deprecation warnings in some tools (pyright in my case). Our minimum Python version is 3.11, so it seems worthwhile to avoid those warnings, and I'm filing this PR as part of familiarising myself with the codebase.
Changes
This change updates the generation of scaffolded types to use the new names, and also adds default values in some cases, where further warnings were previously reported.
As a first step, the "logs" API has been regenerated, so that concrete changes can be inspected. It's not clear to me whether it is desirable or safe to actually update any generated modules yet, though.
Tests
Open question: would it be best to allow later gradual regeneration of scaffolds?
Related