-
Notifications
You must be signed in to change notification settings - Fork 14
refactor!: Introduce fully typed clients [WIP] #554
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
base: master
Are you sure you want to change the base?
Conversation
e470329 to
64a173b
Compare
64a173b to
c410e21
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #554 +/- ##
==========================================
+ Coverage 76.01% 84.85% +8.83%
==========================================
Files 42 41 -1
Lines 2468 3888 +1420
==========================================
+ Hits 1876 3299 +1423
+ Misses 592 589 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| super().__init__(*args, resource_path=resource_path, **kwargs) | ||
|
|
||
| def list(self) -> ListPage[dict]: | ||
| def list(self) -> ListPage[EnvVar]: |
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 ListPage is not fully based on API. API returns only total + items , so the rest is made up: count, offset, limit, desc
This is already in code, but since this aims at improving the API....
Fixing it would complicate the types quite a bit though
|
|
||
|
|
||
| class Data(PaginationResponse): | ||
| items: list[ActorShort] |
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.
How is this generated?
Real response is like this:
"data": {
"total": ...,
"count": ...,
"offset": ...,
"limit": ...,
"desc": ...,
"items": [...
Is the spec incorrect?
| class PricingModel3(Enum): | ||
| FREE = 'FREE' | ||
|
|
||
|
|
||
| class FreeActorPricingInfo(CommonActorPricingInfo): | ||
| pricing_model: Annotated[Literal['FREE'], Field(alias='pricingModel')] |
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.
So is this literal or Enum?
|
|
||
|
|
||
| class Data3(PaginationResponse): | ||
| items: list[WebhookShort] | None = None |
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.
How is this generated?
Real response is like this:
"data": {
"total": ...,
"count": ...,
"offset": ...,
"limit": ...,
"desc": ...,
"items": [...
Is the spec incorrect?
| stats: KeyValueStoreStats | None = None | ||
|
|
||
|
|
||
| class Data7(PaginationResponse): |
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.
How is this generated?
Real response is like this:
"data": {
"total": ...,
"count": ...,
"offset": ...,
"limit": ...,
"desc": ...,
"items": [...
Is the spec incorrect?
| class Data8(BaseModel): | ||
| items: list[Item] | ||
| count: Annotated[float, Field(examples=[2])] | ||
| limit: Annotated[float, Field(examples=[2])] | ||
| exclusive_start_key: Annotated[str | None, Field(alias='exclusiveStartKey', examples=['some-key'])] = None | ||
| is_truncated: Annotated[bool, Field(alias='isTruncated', examples=[True])] | ||
| next_exclusive_start_key: Annotated[str | None, Field(alias='nextExclusiveStartKey', examples=['third-key'])] = None | ||
|
|
||
|
|
||
| class ListOfKeysResponse(BaseModel): | ||
| data: Data8 | ||
|
|
||
|
|
||
| class GetListOfKeysResponse(BaseModel): | ||
| data: ListOfKeysResponse | ||
|
|
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 seems wrong. It looks like double nested data, but in reality, it should be just one level of data.
https://docs.apify.com/api/v2/key-value-store-keys-get
This PR introduces fully typed API clients, with models generated directly from OpenAPI specifications.
Description
pyproject.tomland theMakefile.apify/apify-docsfor details - TODO.apify/apify-sdk-pythonfor details - chore: Adapt to apify-client v3 [WIP] apify-sdk-python#719.Issues
Testing