Skip to content

ASF: Mark optional params as such (X | None) #12614

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

Merged
merged 2 commits into from
May 13, 2025
Merged

Conversation

bblommers
Copy link
Contributor

@bblommers bblommers commented May 13, 2025

Motivation

As discussed in #12588 - if we want to enable MyPy on the entire codebase, one of the first steps would be to make sure that the generated API has the correct types.

Changes

  • Marks optional parameters as such (X | None = None instead of X = None)
  • Updates the test_asf_providers.py::test_provider_signatures to handle all variations of Optional/Union params
  • Updates the API itself

@bblommers bblommers added this to the Playground milestone May 13, 2025
@bblommers bblommers added area: asf semver: patch Non-breaking changes which can be included in patch releases labels May 13, 2025
Copy link

github-actions bot commented May 13, 2025

S3 Image Test Results (AMD64 / ARM64)

  2 files  ±0    2 suites  ±0   8m 45s ⏱️ +32s
488 tests ±0  438 ✅ ±0   50 💤 ±0  0 ❌ ±0 
976 runs  ±0  876 ✅ ±0  100 💤 ±0  0 ❌ ±0 

Results for commit 218d504. ± Comparison against base commit 6910145.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 13, 2025

LocalStack Community integration with Pro

    2 files      2 suites   1h 42m 1s ⏱️
4 425 tests 4 042 ✅ 383 💤 0 ❌
4 427 runs  4 042 ✅ 385 💤 0 ❌

Results for commit 218d504.

♻️ This comment has been updated with latest results.

@bblommers bblommers marked this pull request as ready for review May 13, 2025 10:02
@bblommers bblommers requested a review from thrau as a code owner May 13, 2025 10:02
@bblommers bblommers requested a review from alexrashed May 13, 2025 10:02
Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small and concise change and directly as discussed in the other linked PRs / conversations!
Would it make sense to maybe also update the APIs directly here in the PR in a separate commit and in our downstream project right after merging this one, instead of mixing it with the weekly automatically scheduled execution of the update next Monday? :)

Copy link
Member

@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

Copy link
Contributor

@MEPalma MEPalma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra annotation for SFN is definitely welcome, as is the possibility to use MyPy; thank you!

Just curious, are there plans/or would it be feasible for us to distinguish between Optional[X] and NotRequired[X]? I find that distinction quite useful.

@bblommers
Copy link
Contributor Author

Just curious, are there plans/or would it be feasible for us to distinguish between Optional[X] and NotRequired[X]? I find that distinction quite useful.

@MEPalma I don't think I've ever used NotRequired actually!

Do you find the distinction useful when invoking a method(arg: NotRequired) to better understand the signature, or is it easier during the implementation of that method? As far as I can tell, there is no practical difference for the implementation - so I'm inclined to stick to Optional, just because it's simpler to read/understand.

Copy link
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bblommers bblommers merged commit 9b6ef35 into master May 13, 2025
41 checks passed
@bblommers bblommers deleted the asf-optional-params branch May 13, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: asf semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants