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 synchronous API #2549

Merged
merged 14 commits into from
Dec 18, 2024
Merged

docs/add docstrings to synchronous API #2549

merged 14 commits into from
Dec 18, 2024

Conversation

d-v-b
Copy link
Contributor

@d-v-b d-v-b commented Dec 10, 2024

I add docstrings to the exported functions defined in api/synchronous.py, copy exactly the same functions in api/asynchronous.py, except for a few places where the sync / async functions diverge.

I also add a test to check that docstrings are identical, and another test to check that function signatures are identical, for said paired functions. These tests also get some exceptions for functions that are not quite identical.

closes #2475

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@d-v-b
Copy link
Contributor Author

d-v-b commented Dec 10, 2024

note that some lower-level routines needed their function signatures updating -- it seems like Array.create wasn't fully aware that it takes int for chunks / chunk_shape

@d-v-b d-v-b requested a review from jhamman December 10, 2024 17:36
Copy link
Contributor

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Nice, and great that it caught some dodgy signatures. I left a couple of suggestions/questions

"""
Test that functions in the API module have signatures that are derived from those in the asynchronous API module
"""
if func_name in ("tree", "load", "open", "open_array", "group"):
Copy link
Contributor

Choose a reason for hiding this comment

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

If the signature of two functions is different, shouldn't the docstring be different too. ie., this list and the same list above in test_derived_docstrings should be the same?

In at least tree() this seems to be correct - the docstring for zarr.api.asynchronous.tree needs correcting to say it takes an AsyncGroup as input, at which point it will have a different docstring to zarr.api.synchronous.tree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes i think you are right -- by construction all of the docstrings should be different in their return type annotation, and so this test is currently incorrect (fortunately I guarded for something like this outcome in the test docstring by stating "derived from" rather than "equal to")

@dstansby dstansby added the documentation Improvements to the documentation label Dec 13, 2024
Copy link
Member

@jhamman jhamman left a comment

Choose a reason for hiding this comment

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

👏

Copy link
Contributor

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Marking as requested changes so we don't forget the test needs fixing (see #2549 (comment))

@d-v-b
Copy link
Contributor Author

d-v-b commented Dec 18, 2024

I removed the docstring / function signature tests, because I think they are too complex to implement properly right now. I think this is basically ready.

@d-v-b d-v-b enabled auto-merge (squash) December 18, 2024 21:40
@d-v-b d-v-b merged commit f035d45 into main Dec 18, 2024
32 checks passed
@d-v-b d-v-b deleted the docs/add-docstrings branch December 18, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comprehensive docstrings for all top-level exports
3 participants