Skip to content
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

List typing fixes #287

Merged
merged 6 commits into from
Jul 23, 2024
Merged

List typing fixes #287

merged 6 commits into from
Jul 23, 2024

Conversation

tribble
Copy link

@tribble tribble commented Jul 22, 2024

Description

Rather than check list params at runtime, just define static types. I had to refactor the list resource a bit to accomplish this, as I moved away from using a model for the args and just used a TypedDict

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@tribble tribble requested a review from a team as a code owner July 22, 2024 23:29
@tribble tribble requested review from jonatascastro12 and removed request for a team July 22, 2024 23:29
list_method: Callable = Field(exclude=True)
list_args: ListArgs = Field(exclude=True)
filter_params: FilterParams = Field(exclude=True)
Copy link
Author

Choose a reason for hiding this comment

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

I don't love passing in an entirely separate type for this, but guess what? Python type hinting doesn't support intersection between two TypedDicts. This is why we can't have nice things.

python/typing#1275

Copy link
Author

Choose a reason for hiding this comment

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

... actually, I wonder if all of the list resource params can inherit from ListArgs and add their own specific params. I think that will work out better. Going to convert this back to drafe.

@tribble tribble marked this pull request as draft July 22, 2024 23:55
@tribble tribble marked this pull request as ready for review July 23, 2024 18:48
@tribble tribble requested a review from mattgd July 23, 2024 18:48
@tribble tribble merged commit 3138264 into beta-5.0 Jul 23, 2024
4 checks passed
@tribble tribble deleted the list-typing-fixes branch July 23, 2024 21:45
tribble added a commit that referenced this pull request Jul 30, 2024
* Update ini to pick up more files

* Remove runtime type checking for list types

* Change approach to specifying list params

* Fix after rebase

* Formatting

* Remove som unused imports and switch typed dict import to typing extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants