Add type hints to management#497
Conversation
|
lgtm - thanks @Viicos Just need to fix the build |
516bae2 to
77a1c7c
Compare
|
@adamjmcgrath done (apart from the failing docs, I don't really know how to fix this), sorry for the delay |
|
Thanks @Viicos - will take a look at the docs when I have a moment |
| include_totals: bool = True, | ||
| from_param: str | None = None, | ||
| take: int | None = None, | ||
| ) -> list[dict[str, Any]]: |
There was a problem hiding this comment.
pls, pay attention, here is the wrong return type, the all_organization_members method can also return the dict object if include_totals equals True or Pagination is enabled
{
"members": [{"user_id": "xxxx", ...}, ...],
"start": 0,
"limit": 50,
"total": n
}
There was a problem hiding this comment.
@shchotse This PR is merged, would you mind creating a separate issue? Thanks
There was a problem hiding this comment.
@shchotse thanks. As I said:
This is ready for review, but I might take a second look, probably forgot a few things.
I've tried specifying the correct return type where possible, but otherwise made use of Any. The issue is no OpenAPI file is available, so it's hard to be accurate. By the way some people suggested to auto generate the sdk from an OpenAPI spec, but this usually requires some additional work and the OpenAPI needs to be complete
| include_totals: bool = True, | ||
| fields: List[str] | None = None, | ||
| include_fields: bool = True, | ||
| ) -> List[dict[str, Any]]: |
There was a problem hiding this comment.
I believe this is the wrong type? I think it should be Dict[str, Any]
There was a problem hiding this comment.
@lilidworkin This PR is merged, would you mind creating a separate issue? Thanks
There was a problem hiding this comment.
@lilidworkin thanks. See #497 (comment) for more details
|
Are there any plans to add some more concrete return types? E.g. using It would be a huge win for DX, currently I am maintaining local definitions and doing this: from typing import NotRequired, TypedDict
class Role(TypedDict):
id: str
name: str
description: str
class RolesResponse(TypedDict):
"""https://auth0.com/docs/api/management/v2/roles/get-roles"""
start: int
limit: int
total: int
roles: list[Role]
...
user_roles: RolesResponse = auth0_client.users.list_roles(user_id) |
Fixes #470.
This is ready for review, but I might take a second look, probably forgot a few things.