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

docs: Add docstrings to Seam class #115

Merged
merged 6 commits into from
Jul 25, 2024
Merged

Conversation

andrii-balitskyi
Copy link
Contributor

@andrii-balitskyi andrii-balitskyi commented Jul 10, 2024

wrt #86

@andrii-balitskyi andrii-balitskyi requested a review from razor-x July 10, 2024 13:33
seam/seam.py Outdated Show resolved Hide resolved
seam/seam.py Outdated
Comment on lines 70 to 81
:raises SeamHttpApiError: For general API errors, including
unexpected server responses
:raises SeamHttpUnauthorizedError: When the provided authentication
credentials (api_key or personal_access_token) are invalid
:raises SeamHttpInvalidInputError: When the API request contains
invalid input data
:raises SeamActionAttemptFailedError: When an action attempt fails to
complete successfully (only when wait_for_action_attempt is
enabled)
:raises SeamActionAttemptTimeoutError: When an action attempt exceeds
the specified timeout duration (only when wait_for_action_attempt
is enabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

These are all raised by the individual methods. Does it make sense to put them on the constructor? I wonder what other libs do, since often errors are raised in many places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah I meant to ask about this but forgot. Probably it doesn't make sense to put them all here. Http errors can go to SeamHttpClient docstring and action attempt ones to the ActionAttempts route class docstring. I think SeamInvalidOptionsError and SeamInvalidTokenError is fine to leave here.

I wonder what other libs do, since often errors are raised in many places.

I briefly looked through a couple of libs and it seems that mostly exceptions are documented where they're raised. I also found instances where exception docstring is also propagated up where the method throwing it is used like here.

Even though InvalidOptionsError is raised in get_auth_headers which in turn is called in parse_options that we use in the Seam constructor, I think it still makes sense to document it on the constructor because none of those functions handle the error and it'll get raised when the constructor is called. Plus if the error is not documented on the constructor, it won't be clear from the IDE intellisense that when calling Seam constructor such errors can be raised. Ideally we should document the error on each level where it can be raised?

seam/seam.py Show resolved Hide resolved
@razor-x
Copy link
Contributor

razor-x commented Jul 12, 2024

@DebbieAtSeam Do you want to review the language we use in the docstrings here? See also https://github.com/seamapi/python/pull/113/files#diff-6aa596a1d9b2ede6d6729f736e0d98900fee277a5b3f129509f9485f4ba86d72

@DebbieAtSeam
Copy link

@razor-x Yes, I'd like to do a light copy edit, please. Thanks!

@DebbieAtSeam
Copy link

@razor-x Further, are the items with new docstrings here things that do not exist (and could not be documented once) in a centralized location that could populate to all the SDKs?

@razor-x
Copy link
Contributor

razor-x commented Jul 12, 2024

@DebbieAtSeam

Further, are the items with new docstrings here things that do not exist (and could not be documented once) in a centralized location that could populate to all the SDKs?

There will be similarity across SDKs but it will be language specific. I'd say we should limit the content as much as possible and link to the docs if we need to expand. So, even this sentence feels mostly extraneous

This class provides methods to authenticate and interact with various
Seam API endpoints,
including devices, access codes, action_attempts, and more. It supports authentication via API key or personal access token.

@andrii-balitskyi
Copy link
Contributor Author

@DebbieAtSeam @razor-x, are we good to merge this? Or the docstring language is still to be reviewed?

@DebbieAtSeam
Copy link

Let's merge it now and then think about editing it and syncing the wording with the JS version later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants