Skip to content

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

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

Open
wants to merge 9 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

@dstansby
Copy link
Contributor

dstansby commented Mar 1, 2025

I think my suggested change (that I applied) revealed (sort of) a real issue - Checksum32 is a base class, not a codec that can be used by itself. I've made this better by making it an abstract base class in #711 - if/when that's merged, we can update the check here in the test to not isinstance(codec, abc.ABC).

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