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

Type hints #199

Open
guacs opened this issue Aug 8, 2023 · 2 comments
Open

Type hints #199

guacs opened this issue Aug 8, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@guacs
Copy link

guacs commented Aug 8, 2023

I was wondering if there is any interest in specifying the types of each response instead of just using Any. The types could be taken from the official API written in Typescript. I looked through #9 and so instead of using dataclasses, I'm proposing type hinting everything using TypedDict. This would make things quite easy for the users since they would get features like autocomplete and would be able run their code through a type checker. Essentially I'm suggesting something like the following:

class Database(TypedDict):
    ...

class DatabasesEndpoint(Endpoint):

    def retrieve(self, db_id: str) -> Database:
        ...

However, one possible issue I'm seeing with this approach is that the return types of the endpoints currently are not suitable for this as far as I know. The SyncAsync[T] does not work well with type checkers so instead separate endpoints classes for synchronous and asynchronous endpoints would need to be maintained.

@ramnes
Copy link
Owner

ramnes commented Aug 8, 2023

Yes, I'm definitely interested if you're willing to add them and most importantly maintain them afterwards to stay up to date with the TS client. :)

@guacs
Copy link
Author

guacs commented Aug 9, 2023

Yupp I'm willing to add them and maintain them as well. I'll start working on it and hopefully if this makenotion/notion-sdk-js#294 gets resolved, then maintenance would be much easier.

@ramnes ramnes added enhancement New feature or request help wanted Extra attention is needed labels Aug 10, 2023
@ramnes ramnes changed the title Feature Request: add types for all responses using TypedDict Type hints Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants