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

(chore) Type hints for abc codec codec_id attribute #702

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

d-v-b
Copy link
Contributor

@d-v-b d-v-b commented Feb 9, 2025

I'm not sure how to type the buffer parameters. As long as we have a pickle codec, I don't think it's possible to restrict the return type of decode to anything narrower than object.

  • Unit tests and/or doctests in docstrings
  • Tests pass locally
  • Docstrings and API docs for any new/modified user-facing classes and functions
  • Changes documented in docs/release.rst
  • Docs build locally
  • GitHub Actions CI passes
  • Test coverage to 100% (Codecov passes)

@d-v-b d-v-b changed the title (chore) Type hints for abc codec (chore) Type hints for abc codec codec_id attribute Feb 12, 2025
@d-v-b
Copy link
Contributor Author

d-v-b commented Feb 12, 2025

i'm just annotating the type of the codec_id attribute -- it's a ClassVar[str], (no default value) instead of str | None = None

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.96%. Comparing base (a2bdbe5) to head (c22b97f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #702   +/-   ##
=======================================
  Coverage   99.96%   99.96%           
=======================================
  Files          63       63           
  Lines        2754     2754           
=======================================
  Hits         2753     2753           
  Misses          1        1           
Files with missing lines Coverage Δ
numcodecs/abc.py 100.00% <100.00%> (ø)
numcodecs/tests/test_registry.py 100.00% <ø> (ø)

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.

👍 , just one suggestion, feel free to take or leave and then merge

@@ -34,8 +34,8 @@ def test_all_classes_registered():
if (
inspect.isclass(obj)
and issubclass(obj, numcodecs.abc.Codec)
and hasattr(obj, 'codec_id')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
and hasattr(obj, 'codec_id')
and obj is not numcodecs.abc.Codec

I think is a bit clearer in intent (we don't want or need the base codec to be registered)?

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.

2 participants