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

Add type hints to zarr.create #1536

Merged
merged 13 commits into from Dec 8, 2023
Merged

Conversation

dstansby
Copy link
Contributor

@dstansby dstansby commented Oct 1, 2023

This PR adds type hints to zarr.creation.create().

I couldn't find any discussion of adding type hints to zarr in the issues or discussion forums, so not sure if this is welcome - I would definitely personally find it helpful to have type hints throughout the codebase, and would be happy to chip away at adding them if they are. But definitely understand if it would be useful to have a wider discussion separate to this PR about adding type hinting to zarr before going any further.

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)

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Oct 1, 2023
zarr/creation.py Show resolved Hide resolved
zarr/creation.py Outdated Show resolved Hide resolved
zarr/sync.py Outdated Show resolved Hide resolved
zarr/creation.py Outdated Show resolved Hide resolved
zarr/creation.py Outdated Show resolved Hide resolved
@d-v-b
Copy link
Contributor

d-v-b commented Oct 3, 2023

I like this! I left some comments. Having started one of these "add types to zarr" endeavors before, I understand that it can feel unbounded, so I respect your restraint in only adding types where you did :)

Copy link
Contributor

@d-v-b d-v-b left a comment

Choose a reason for hiding this comment

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

👍

@d-v-b
Copy link
Contributor

d-v-b commented Oct 11, 2023

any objections to merging this?

@d-v-b
Copy link
Contributor

d-v-b commented Oct 25, 2023

I'm kicking off the gha workflows, assuming those pass I'm going to merge this unless there are any objections.

zarr/util.py Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Oct 31, 2023
@codecov
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Merging #1536 (73cedea) into main (cf32382) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1536      +/-   ##
==========================================
- Coverage   99.99%   99.99%   -0.01%     
==========================================
  Files          37       38       +1     
  Lines       14738    14599     -139     
==========================================
- Hits        14737    14598     -139     
  Misses          1        1              
Files Coverage Δ
zarr/_storage/store.py 100.00% <100.00%> (ø)
zarr/creation.py 100.00% <100.00%> (ø)
zarr/storage.py 100.00% <100.00%> (ø)
zarr/sync.py 100.00% <100.00%> (ø)
zarr/tests/test_core.py 99.94% <100.00%> (-0.01%) ⬇️
zarr/types.py 100.00% <100.00%> (ø)
zarr/util.py 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes

@joshmoore
Copy link
Member

I know that @d-v-b and I tend to be fans, but this feels like something that others may want to take a look. Anyone want us to hold merging, @zarr-developers/python-core-devs?

@d-v-b
Copy link
Contributor

d-v-b commented Nov 2, 2023

Since this doesnt affect runtime at all, I think its safe to merge this.

@joshmoore
Copy link
Member

It is adding a new public module though. I would give it until next week following https://github.com/zarr-developers/governance/blob/main/GOVERNANCE.md#decision-making-process

"""Base class for synchronizers."""

def __getitem__(self, item):
...
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts welcome on how to make codecov happy with these lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't find anything obvious in https://docs.codecov.com/docs/ignoring-paths, seems like it only has per-file granularity. Since we know the decrease in coverage isn't meaningful, I'd be fine ignoring it here. In the future maybe we put protocols in types.py (either a module-local one, or a zarr-wide one) and tell codecov to ignore it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the code coverage config to ignore lines that are "...".

Copy link
Contributor

Choose a reason for hiding this comment

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

good idea!

zarr/creation.py Outdated Show resolved Hide resolved
@jhamman
Copy link
Member

jhamman commented Dec 7, 2023

@d-v-b - if you are happy here, would you mind giving this a merge?

Thanks @dstansby for the contribution here. FYI - we're planning much deeper type coverage for v3, if you are up to help in that effort, your contributions would be more than welcome (#1593, etc.).

@d-v-b d-v-b merged commit 4d79cfc into zarr-developers:main Dec 8, 2023
20 of 21 checks passed
@d-v-b
Copy link
Contributor

d-v-b commented Dec 8, 2023

thanks @dstansby! and please feel free to dive in to the v3 effort!

jhamman pushed a commit to jhamman/zarr-python that referenced this pull request Jan 24, 2024
* Add type hints to zarr.create

* Use protocol for MetaArray

* Use protocol for Synchronizer

* Fix Path typing

* Add release note

* Fix dim separator typing

* Ignore ... in coverage reporting

* Fix chunk typing

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
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.

None yet

5 participants