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

Check tests folder with mypy #2150

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

TomAugspurger
Copy link
Contributor

Should we lint (some of?) or tests folder with mypy? This revealed some discrepancies between our type annotations and our usage in the tests, so I think it'd be good to include them. For example, some of the tests used something like

Array.create(shape=100`, ...)

as a shorthand for

Array.create(shape=(100,), ...)

But the type for shape was just ChunkCoords, which is tuple[int, ...]. If we want to allow this, then I think it's probably best to update the types to make that clear.

That said, there's a bunch of errors (399 remaining in tests/v3, 2009 in tests. Some of these are correct but annoying, like all the assert isinstance(arr, Array) in this PR, which was needed to convince mypy that zarr.open() had returned an Array and not a Group.

I'd propose adding tests/v3 to the list of checked files.

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)

src/zarr/core/array.py Outdated Show resolved Hide resolved
@dstansby
Copy link
Contributor

dstansby commented Sep 4, 2024

I think this is a great idea 👍 Is it worth reviewing this PR now, or are you intending to expand it to some other test files first?

@TomAugspurger
Copy link
Contributor Author

I think the rough plan should be

  1. Wait for [v3] h5py compat methods on Group #2128 before merging his.
  2. Make the updates in several batches (expanding the number of files checked, and making whatever changes to the type annotations / code is necessary to support the API)

I think doing it all in one shot would be a mistake, since we are having to make some "runtime" changes to match the usage. And we might decide that some of the usage in the tests folder isn't desirable.

@jhamman
Copy link
Member

jhamman commented Sep 4, 2024

Wait for #2128 before merging his.

@TomAugspurger TomAugspurger marked this pull request as ready for review September 5, 2024 15:13
@jhamman jhamman merged commit e8800b0 into zarr-developers:v3 Sep 6, 2024
26 checks passed
@TomAugspurger TomAugspurger deleted the user/tom/fix/lint-tests branch September 6, 2024 18:18
@dstansby dstansby mentioned this pull request Sep 8, 2024
6 tasks
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.

4 participants