Skip to content

ASF: Ignore optional-ness when comparing argument types #12605

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 1 commit into from
May 12, 2025

Conversation

bblommers
Copy link
Contributor

Motivation

The API currently marks everything as required, and optional args are configured as:

arg: ArgType = None

which is obviously incorrect.

Implementations should be allowed to do this correctly:

arg: ArgType | None = None

But in order for that to work, we need to change the test_asf_providers.py. That test verifies that the signature is exactly the same. This PR makes the test assertions more flexible, so that an argument type of X | None is considered equal to X.

Changes

  • Make the comparison function more flexible to ignore None-types in argument types
  • Add some more specific error messages when the comparison fails
  • Changes the argument types in the Transcribe provider to verify that new assertions work

Testing

Some manual testing was done to verify that the new assertions work, i.e. that a useful error message is thrown when the types are actually different:

>        assert sub_type == base_type, f"Types for {kwarg} are different - {sub_type} instead of {base_type}"
E        AssertionError: Types for job_name_contains are different - [<class 'str'>, <class 'int'>] instead of [<class 'str'>]

TODO

Follow up PR's will:

  • Correct the API generation to have the correct argument types
  • Correct the implementation of all services to have the correct argument types

Related

See #12588 where we kicked this conversation first off.

@bblommers bblommers added this to the Playground milestone May 12, 2025
@bblommers bblommers requested a review from alexrashed May 12, 2025 10:52
@bblommers bblommers added the semver: patch Non-breaking changes which can be included in patch releases label May 12, 2025
Copy link

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 44m 12s ⏱️ + 1m 11s
4 425 tests ±0  4 042 ✅ ±0  383 💤 ±0  0 ❌ ±0 
4 427 runs  ±0  4 042 ✅ ±0  385 💤 ±0  0 ❌ ±0 

Results for commit a11bc56. ± Comparison against base commit e7383de.

@bblommers bblommers marked this pull request as ready for review May 12, 2025 12:59
@bblommers bblommers requested a review from sannya-singal as a code owner May 12, 2025 12:59
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.

Nice! Really great iterative work to get the typing of the generated APIs in order, where this is the very first step! 💯 🦸🏽
Once we have everything over the line, we can remove this part again, but for now this change allows us to work with small iterations!

@bblommers
Copy link
Contributor Author

@sannya-singal Considering you already approved in #12588, I'll consider that as a transitive approval, also applicable to this PR 😄

@bblommers bblommers merged commit b961fee into master May 12, 2025
35 checks passed
@bblommers bblommers deleted the asf-type-comparison-ignore-optional branch May 12, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants