Skip to content

feat(pickle): deprecate the Pickle codec, warning on construction - #4

Open
d-v-b wants to merge 6 commits into
mainfrom
feat/deprecate-pickle
Open

d-v-b wants to merge 6 commits into
mainfrom
feat/deprecate-pickle

Conversation

@d-v-b

@d-v-b d-v-b commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

The Pickle codec is deprecated and will be removed in numcodecs 0.19.0. Constructing it, directly or through numcodecs.get_codec({"id": "pickle"}), emits a DeprecationWarning. Encoding and decoding still work until removal, and decoding still requires the opt-in described in GHSA-jqc8-qjfv-5m6r. To encode arrays of Python objects, use VLenUTF8, VLenBytes, VLenArray, JSON or MsgPack instead. Refs zarr-developers#706.

Design
  • Where it warns: Pickle.__init__ only. Every route to the codec goes through the constructor: Pickle(...), numcodecs.Pickle, Pickle.from_config, get_codec({"id": "pickle"}), and any downstream library that resolves the codec from array metadata. That makes construction the single place to warn, and it fires once per codec instance, when the array is opened or the codec is chosen, rather than once per chunk. The agent did not add a warning to encode/decode: it would repeat per chunk, decode is already gated by the advisory's opt-in, and the warning would arrive after the codec was already selected.
  • Reads of existing data are not broken. The warning does not change behavior unless the caller escalates DeprecationWarning to an error. The decode gate from GHSA-jqc8-qjfv-5m6r is untouched.
  • Warning class: DeprecationWarning, matching every earlier numcodecs deprecation: the numcodecs.zarr3 module, crc32c, PCodec(delta_spec="none"), and the blosc helper functions (via deprecated). Python hides DeprecationWarning by default unless it is attributed to __main__, so the warning uses skip_file_prefixes (Python >= 3.12, the minimum supported) to attribute it to the first frame outside numcodecs. A user calling get_codec({"id": "pickle"}) from a script sees it, and downstream test suites with filterwarnings = error see it at their own call site. A plain stacklevel=2 would attribute the get_codec path to numcodecs/abc.py, where it is hidden. FutureWarning would be visible to every end user, but it would break with precedent; reviewers may prefer it given the security angle.
  • Removal target: 0.19.0. The blosc helpers were deprecated in 0.15.0 and removed in 0.16.0, so the precedent is one minor release. The agent assumed the next release is 0.18.0, since Unreleased already adds a dependency (packaging). If this ships in a 0.17.x patch, the 0.19.0 target still leaves at least one minor release. The version lives in _REMOVAL_VERSION, used by the message, and in the docstring, codec docs page and release note.
  • Message. It describes the current state and the alternatives: VLenUTF8 for strings, VLenBytes for bytes, VLenArray for variable-length numeric arrays, and JSON or MsgPack for mixed objects. It also states why: decoding can execute arbitrary code, and pickled data can only be read by Python.
Changes
  • src/numcodecs/pickles.py: adds the warning in __init__, a deprecation paragraph and a numpydoc Warns section in the class docstring, and lists the alternative codecs in See Also. The doctest example builds the codec inside warnings.catch_warnings(), because --doctest-modules runs with warnings as errors.
  • docs/other/pickles.md: adds a "Deprecated" admonition, above the existing security warning, that links to the alternative codecs.
  • docs/release.md: adds an Unreleased → Deprecations entry.
  • tests/test_pickles.py:
    • test_construction_warns is parametrized over Pickle, numcodecs.Pickle, Pickle.from_config, get_codec and get_codec with a protocol. For each, it asserts that exactly one warning is raised, that the warning is attributed to the test file rather than to numcodecs internals, that the message names the removal version and every alternative, and that encode/decode still round-trip with no further warnings.
    • test_construction_raises_when_deprecation_warnings_are_errors covers the one error case the warning adds.
    • test_decode_refused_without_opt_in is kept unchanged.
    • The tests that predate the deprecation ignore the warning through a module-level pytestmark. The import-time codec list is built inside catch_warnings.
    • After merging main, two newer tests that construct Pickle get the same filter, scoped to the deprecation message: test_config_round_trip[pickle] in tests/test_codec_contract.py (test: check the Codec contract for every codec and add static type tests zarr-developers/numcodecs#906) and test_pickle in tests/typing/test_object_codec_types.py (feat(typing): ship py.typed and check numcodecs with strict mypy zarr-developers/numcodecs#915).
    • The agent checked that the attribution assertion matters: with stacklevel=2 in place of skip_file_prefixes, the three from_config/get_codec cases fail.
Verification
  • After merging main (through feat(typing): ship py.typed and check numcodecs with strict mypy zarr-developers/numcodecs#915), the agent ran the full suite with doctests (pytest tests src/numcodecs) on Python 3.13, with msgpack, pcodec, zfpy, zarr 3.4.2, crc32c and google-crc32c installed: 1055 passed, 21 skipped. The skips are cupy, free-threading-only and legacy-crc32c-only tests.
  • The CI typing checks pass locally: mypy --config-file pyproject.toml src tests, mypy --config-file tests/typing/mypy.ini tests/typing, and pyright -p tests/typing.
  • SKIP=mypy pre-commit run --all-files passes. The mypy hook was skipped because zfpy does not build on the pre-commit interpreter (CPython 3.15t); the mypy runs above cover it.
  • A Sphinx HTML build of the docs gives no warnings for the changed pages, and the admonition links resolve.
Downstream impact (zarr-python)

The agent checked zarr-python by reading hand-written v2 arrays with each released version. zarr derives object_codec_id from the first entry in filters + compressor whose id is in zarr.core.dtype.common.OBJECT_CODEC_IDS, and from 3.1.0 on, only vlen-utf8 and vlen-bytes resolve to a data type. Two layouts behave differently:

Layout zarr 3.0.x zarr 3.1.0 to 3.4.1 zarr 3.4.2
filters=[pickle], dtype="|O" (what zarr 2's object_codec=Pickle() wrote) opens; decode needs the numcodecs opt-in ValueError: No Zarr data type found at open same as 3.1
filters=[vlen-utf8], compressor=pickle opens; decode needs the numcodecs opt-in opens; decode needs the numcodecs opt-in opens; decode needs both array.allow_unsafe_pickle_decode (zarr-developers/zarr-python#4465) and the numcodecs opt-in
  • Where the array opens, zarr builds the codec through numcodecs.get_codec, so this warning fires once at open, attributed to zarr/core/metadata/v2.py. Python's default filters hide it there; downstream test suites that turn warnings into errors see it.
  • The second layout is unusual for real data, but it is the one crafted metadata would use to reach Pickle.decode, so both gates still matter.
  • zarr-python 2 imports numcodecs.blosc.cbuffer_sizes at import time, which was removed in numcodecs 0.16 (checked for 2.18.2, 2.18.4 and 2.18.7), and 2.18.7 pins numcodecs<0.16. So zarr 2 never runs with a numcodecs that has the decode gate or this warning.
  • There is no zarr.codecs.numcodecs.Pickle wrapper.

zarr-python follow-ups, not part of this PR:

  1. Needed before this ships: zarr 3.4.2's tests/test_v2.py constructs Pickle() (the #4465 tests), and zarr runs pytest with filterwarnings = ["error", ...]. Once this release is out, those tests fail on the deprecation warning. They need @pytest.mark.filterwarnings("ignore:The Pickle codec is deprecated:DeprecationWarning") or a matching entry in pyproject.toml.
  2. Give a targeted error when v2 metadata resolves object_codec_id to pickle, in place of the generic "No Zarr data type found" message.
  3. Remove "pickle" from ObjectCodecID / OBJECT_CODEC_IDS, and remove the array.allow_unsafe_pickle_decode gate, once numcodecs removes the codec (0.19.0).

🤖 Generated with Claude Code

…s#903)

* ci: remove the release-notes Pull Request Labeler workflow

Its config matches docs/release.rst, which no longer exists (release notes
moved to docs/release.md), so it has not labelled a pull request in a long
time. It also ran an unpinned actions/labeler@main under
pull_request_target with a write token.

Assisted-by: ClaudeCode:claude-opus-5.5

* ci(wheels): remove the test_dist_pypi job

The job downloaded the wheels and sdist and only ran ls on them.

Assisted-by: ClaudeCode:claude-opus-5.5

* ci: only run on pushes to main, version tags and pull requests

Pushes to any branch triggered Tests, Tests on i386 and Wheels, so a branch
with an open pull request ran every workflow twice per commit. Push
triggers now fire only for main (and v* tags for Wheels, which upload_pypi
needs). Tests and Tests on i386 gain workflow_dispatch so a branch can
still be tested without opening a pull request.

Assisted-by: ClaudeCode:claude-opus-5.5

* ci(wheels): run the test suite against every built wheel

The Tests workflow builds numcodecs with meson's avx2=auto, but the wheels
on PyPI are built with -Davx2=disabled (and -Dsse2=disabled on macOS
arm64), and the Wheels job only checked that numcodecs imports. So the SIMD
configuration PyPI users run never went through pytest. cibuildwheel now
runs pytest on each wheel, from copies of tests/ and fixture/ so numcodecs
is imported from the installed wheel rather than the source tree. The
existing free-threading GIL check is kept and moved to pyproject.toml.

The manylinux images have no zstd CLI, so zstd_cli_available() now
returns False instead of raising FileNotFoundError when it is missing.

Assisted-by: ClaudeCode:claude-opus-5.5

* ci: test 3.12 and 3.14t only on non-Linux-x86 platforms

The Tests build matrix ran all six Python versions on all five platforms
(30 jobs). It now runs every version on ubuntu-latest, which also uploads
coverage, and 3.12 and 3.14t on ubuntu-22.04-arm, windows-latest,
macos-15-intel and macos-15 (14 jobs). Past failures were almost always
on every platform or tied to one Python version; the platform-specific
ones were on macOS Intel and free-threaded macOS, which stay covered. The
wheel builds now run the test suite on every version on every platform.

Assisted-by: ClaudeCode:claude-opus-5.5

* ci(zarr): test the oldest supported and the latest zarr releases

The Zarr integration matrix tested 3.0.8, 3.1.6 and main. numcodecs.zarr3
requires zarr >= 3.1.3, so test_zarr3.py skipped on 3.0.8 and that job
tested nothing, and the newest release was not tested at all. Test 3.1.3
(the oldest supported release), the latest release (unpinned, so it does
not go stale) and main, and rename the matching dependency groups. Also
fix docs/contributing.md, which named test-zarr-312 and test-zarr-313
groups that did not exist.

Assisted-by: ClaudeCode:claude-opus-5.5

* ci(i386): use Alpine's numpy instead of building it from source

numpy publishes no i386 musllinux wheels, so the i386 job spent about 3.5
of its 5.5 minutes building numpy from source. The script now installs into
the container's system Python, where Alpine's py3-numpy already satisfies
numpy>=2: uv does not treat packages seen through a
--system-site-packages venv as installed. Every uv pip install passes
--only-binary numpy so uv fails rather than silently rebuilding numpy, and
the script checks that the numpy in use is still the apk-installed one.

Assisted-by: ClaudeCode:claude-opus-5.5

* docs: add release note for the CI trim

Assisted-by: ClaudeCode:claude-opus-5.5
Constructing Pickle, directly or through get_codec({"id": "pickle"}),
now emits a DeprecationWarning naming the planned removal in 0.19.0
and the codecs to use for object data instead (VLenUTF8, VLenBytes,
VLenArray, JSON, MsgPack). The warning is attributed to the first
caller outside numcodecs, so it points at user code or at the library
that selected the codec from array metadata. Encoding and decoding are
unchanged, and decoding still requires the opt-in from
GHSA-jqc8-qjfv-5m6r.

Refs: zarr-developers#706

Assisted-by: ClaudeCode:claude-opus-5.5
…sts (zarr-developers#906)

Add tests/test_codec_contract.py, which runs every registered codec through
the behavior the Codec base class promises: encode and decode return buffers,
decode(out=...) returns the caller's out, and get_config round-trips through
from_config. Known violations are strict xfails, so fixing one forces its
entry to be removed.

Add tests/typing, where assert_type checks (verified by mypy and pyright in
strict mode) sit next to runtime assertions (verified by pytest), and a
`typing` CI job that runs both checkers plus the repository's own mypy
configuration. The type checkers are pinned in a new `typing` dependency
group.

Assisted-by: ClaudeCode:claude-opus-5-5
…zarr-developers#907)

* test: check the Codec contract for every codec and add static type tests

Add tests/test_codec_contract.py, which runs every registered codec through
the behavior the Codec base class promises: encode and decode return buffers,
decode(out=...) returns the caller's out, and get_config round-trips through
from_config. Known violations are strict xfails, so fixing one forces its
entry to be removed.

Add tests/typing, where assert_type checks (verified by mypy and pyright in
strict mode) sit next to runtime assertions (verified by pytest), and a
`typing` CI job that runs both checkers plus the repository's own mypy
configuration. The type checkers are pinned in a new `typing` dependency
group.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix: return the caller's out from decode(buf, out=out) in every codec

The Codec docstring says decode writes into `out`, and callers expect `out`
back. Ten codecs (Zlib, BZ2, LZMA, Base64, Shuffle, ZFPY, PCodec and the
three VLen codecs) rebound `out` to a flattened view and returned that, and
numcodecs.compat.ndarray_copy did the same for any `out` that was not an
ndarray, which every filter and checksum codec inherited. The decoded bytes
were already in the caller's buffer; only the returned object changes.

JenkinsLookup3.decode now accepts any contiguous writable buffer as `out`
and checks its size, and Fletcher32.decode returns a uint8 ndarray instead of
a Cython memoryview slice that no type annotation could name.

The strict xfails in tests/test_codec_contract.py are removed.

Assisted-by: ClaudeCode:claude-opus-5-5
…r-developers#915)

* test: check the Codec contract for every codec and add static type tests

Add tests/test_codec_contract.py, which runs every registered codec through
the behavior the Codec base class promises: encode and decode return buffers,
decode(out=...) returns the caller's out, and get_config round-trips through
from_config. Known violations are strict xfails, so fixing one forces its
entry to be removed.

Add tests/typing, where assert_type checks (verified by mypy and pyright in
strict mode) sit next to runtime assertions (verified by pytest), and a
`typing` CI job that runs both checkers plus the repository's own mypy
configuration. The type checkers are pinned in a new `typing` dependency
group.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix: return the caller's out from decode(buf, out=out) in every codec

The Codec docstring says decode writes into `out`, and callers expect `out`
back. Ten codecs (Zlib, BZ2, LZMA, Base64, Shuffle, ZFPY, PCodec and the
three VLen codecs) rebound `out` to a flattened view and returned that, and
numcodecs.compat.ndarray_copy did the same for any `out` that was not an
ndarray, which every filter and checksum codec inherited. The decoded bytes
were already in the caller's buffer; only the returned object changes.

JenkinsLookup3.decode now accepts any contiguous writable buffer as `out`
and checks its size, and Fletcher32.decode returns a uint8 ndarray instead of
a Cython memoryview slice that no type annotation could name.

The strict xfails in tests/test_codec_contract.py are removed.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(typing): correct registry, compat and NDArrayLike annotations and add __all__

Several annotations described something other than what the code does:

- codec_registry holds classes: dict[str, type[Codec]], not dict[str, Codec].
- entries holds single entry points: dict[str, EntryPoint].
- ndarray_copy returned NDArrayLike, but hands back `src` unchanged (often
  bytes) when `dst` is None. It is now overloaded on `dst`.
- NDArrayLike, DType and FlagsObj declared settable attributes, so no
  numpy.ndarray satisfied NDArrayLike under mypy or pyright. They now declare
  read-only properties. The isinstance cache moves to module level, because
  a protocol without annotations of its own would otherwise pick up the
  metaclass's annotation as a required member.

The compat functions annotate their parameters with a new BufferLike alias
(collections.abc.Buffer | NDArrayLike), is_ndarray_like returns TypeIs, and
get_codec/register_codec are annotated. register_codec now refuses a class
without a codec_id instead of registering it under None, and get_codec warns
(DeprecationWarning) when an entry point loads a class that does not
subclass Codec, so that `-> Codec` can become true.

numcodecs/__init__.py defines __all__, so that type checkers treat the
re-exported codec classes as public once numcodecs ships py.typed.

mypy now checks against Python 3.12, the oldest supported version; doing so
caught `typing.TypeIs`, which only exists from 3.13 and now comes from
typing_extensions.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(abc): annotate the Codec base class and add structural codec protocols

Codec.encode and Codec.decode were unannotated with docstring-only bodies,
so mypy saw them as Any and pyright inferred that both return None, which
made every typed subclass an "incompatible override" under pyright.

- encode/decode take and return BufferLike (collections.abc.Buffer |
  NDArrayLike), with `buf` positional-only so that subclasses may rename it.
- decode is overloaded so that decode(buf, out=out) returns the type of
  `out`, which every codec now honors.
- codec_id is declared `str` without a default instead of `str | None =
  None`. It is not a ClassVar: with ClassVar, Codec instances do not match
  protocols that declare codec_id as a plain attribute (zarr-python's
  Numcodec) or as a property, under mypy or pyright.
- get_config returns Mapping[str, Any], so that concrete codecs can later
  return per-codec TypedDicts, and from_config returns Self.

numcodecs.abc also exports CodecProtocol and the three Zarr v3 codec kinds
(BytesBytesCodec, ArrayArrayCodec, ArrayBytesCodec) as structural
protocols, so consumers can type code that accepts any codec-like object.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(typing): ship .pyi stubs for the Cython extension modules

blosc, zstd, lz4, vlen, fletcher32, jenkins, compat_ext and _shuffle had no
stubs, so type checkers saw Blosc, Zstd, LZ4, Fletcher32 and the VLen codecs
as unknown, and numcodecs' own mypy run silently treated them as Any. Each
module now has a stub next to its .pyx, installed by meson.

The stubs follow probed behavior: the compressors return bytes, or `out`
itself when it is given; Fletcher32.decode returns a uint8 ndarray; the VLen
codecs encode to bytearray and decode to object arrays. VLenArray.encode
takes an object array only, since numpy turns a list of equal-length arrays
into a 2-D array.

The typing CI job runs mypy.stubtest against the installed extensions, with
an allowlist for Cython artifacts (__test__, __pyx_capi__, and the `(self, /)`
signature Cython reports for argument-less module functions).

Checksum32.checksum is declared positional-only, so that JenkinsLookup3 can
use jenkins_lookup3 (whose parameters are named differently) as its checksum;
it is wrapped in staticmethod so type checkers do not bind it as a method.
It was never bound at runtime, being a builtin function.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(typing): annotate the compressor codecs with per-codec config TypedDicts

Zlib, GZip, BZ2, LZMA and Base64 annotate __init__, encode (-> bytes) and
decode (overloaded: bytes without `out`, the type of `out` with it), and
Blosc, Zstd and LZ4 get the same through their stubs. Each get_config
returns a TypedDict of the codec's parameters; for codecs that inherit the
base implementation it is a cast of the inherited dict, so subclasses that
add attributes keep them in their configuration as before.

numcodecs.abc.CodecConfig is the common base: `id: str`, with PEP 728
`extra_items=ReadOnly[JSON]`, which lets pyright treat any codec
configuration as a Mapping[str, JSON] (and as Zarr v2 codec metadata).
mypy does not implement PEP 728 yet and sees a plain TypedDict. JSON uses
Sequence/Mapping, matching zarr_metadata's JSONValue. `extra_items` needs
typing_extensions >= 4.13 at runtime.

The Cython modules define their config TypedDicts with the functional syntax,
which Cython compiles; the stubs declare the same types with the class
syntax.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(typing): annotate the checksum codecs and make JenkinsLookup3 configs JSON

CRC32, Adler32, CRC32C, JenkinsLookup3 and Fletcher32 are annotated, and
their configurations are typed: Checksum32Config has an optional `location`
(present only when passed to the constructor, which matches the Zarr v3
crc32c codec having no configuration), and JenkinsLookup3Config adds
`initval` and `prefix`.

Typing the JenkinsLookup3 configuration exposed a bug: with a prefix,
get_config() held a numpy array, so the configuration could neither be
serialized to JSON nor passed back to get_codec. It now reports the prefix
as a list of ints, which the constructor accepts.

Checksum32.encode and decode are annotated with the union of what the
family returns (uint8 ndarrays for CRC32/Adler32/CRC32C; bytes and a
memoryview for JenkinsLookup3, which overrides both). Changing
JenkinsLookup3's return types instead would break callers that compare its
output with bytes, as its own tests do.

Checksum32.decode checks the byte length of its input instead of len(buf),
which counted only the first axis of a multidimensional array. This
overlaps upstream PR zarr-developers#891.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(typing): annotate the filter codecs

AsType, Delta, Quantize, FixedScaleOffset, BitRound, PackBits, Shuffle and
Categorize annotate their constructors, encode/decode (with the `out`
overloads) and get_config, each returning its own CodecConfig subclass.

- The numeric filters return ndarrays of the codec's dtypes, which numpy's
  types cannot express from a runtime dtype, so they are npt.NDArray[Any].
- BitRound returns NDArrayLike: it works on ndarray-likes such as cupy arrays
  and may return its input unchanged.
- PackBits encodes to uint8 and decodes to bool; Shuffle works on uint8
  bytes, and its encode also takes `out`.
- FixedScaleOffset's `offset` and `scale` are `float`, which covers the ints
  its configuration echoes back when ints were passed.
- Categorize accepts a plain iterable of strings when its dtype is object.

Every filter satisfies numcodecs.abc.ArrayArrayCodec.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(typing): annotate the object and array-to-bytes codecs

JSON, MsgPack, Pickle, VLenUTF8, VLenBytes, VLenArray, ZFPY and PCodec are
annotated, with config TypedDicts.

- JSON and MsgPack encode any array-like and decode to an ndarray whose dtype
  and shape come from the payload.
- Pickle encodes any object and decodes to Any, which is the truth: it
  returns whatever was pickled.
- ZFPY keeps the base `BufferLike` parameter, raising at runtime for anything
  but a C-contiguous numpy array, rather than narrowing the parameter type and
  breaking substitutability.
- PCodec's spec literals get names (ModeSpecName, DeltaSpecName,
  PagingSpecName) shared by its constructor and configuration.

The object codecs now pass `out` through ensure_ndarray before np.copyto,
which returns the same array for an ndarray `out` and lets the call
type-check against BufferLike.

Assisted-by: ClaudeCode:claude-opus-5-5

* feat(typing): ship py.typed and check numcodecs with strict mypy

numcodecs now ships a PEP 561 py.typed marker, installed by meson, so type
checkers read its annotations and the Cython stubs instead of treating the
package as untyped.

Against a built wheel, a downstream consumer under mypy --strict and pyright
strict now gets real types for get_codec, the registry, Codec methods
(including decode(out=...)), every concrete codec and the compat helpers,
where it got Any (mypy) or None and Unknown (pyright) before. pyright's
--verifytypes completeness goes from 22.1% to 99.3% (699 known, 5 ambiguous,
0 unknown symbols).

To get there:

- The remaining strict-mode errors in src are fixed: values from untyped
  optional dependencies (zfpy, pcodec, msgpack, google_crc32c) are bound to
  annotated names, and the NDArrayLike metaclass subclasses
  typing._ProtocolMeta, which typeshed declares, instead of
  Protocol.__class__, which type checkers see as Any and which made every
  BufferLike annotation "partially unknown".
- Instance attributes on the filter codecs and ZFPY are annotated.
- Codec.from_config's `config` is no longer positional-only, so Codec matches
  protocols that declare it as a regular parameter (zarr-python's Numcodec).

The repository's mypy configuration is strict, with mypy_path = src and
ignore_missing_imports only for the untyped optional dependencies. Tests keep
their previous treatment (unannotated test functions are not checked).
pre-commit runs mypy 2.4.1, matching the pinned CI version. The typing CI
job checks that the installed package carries py.typed and the stubs.

Assisted-by: ClaudeCode:claude-opus-5-5

* style: sort test imports now that the Cython modules have stubs

With .pyi stubs next to the .pyx sources, ruff resolves numcodecs.blosc,
numcodecs.zstd, numcodecs.fletcher32 and numcodecs.jenkins as first-party
modules and wants them grouped with the other numcodecs imports.

Assisted-by: ClaudeCode:claude-opus-5-5

* ci: allow the PEP 705 keys stubtest reports on the Cython config TypedDicts

The Cython modules create their config TypedDicts at runtime with
typing.TypedDict, which adds __mutable_keys__ and __readonly_keys__;
stubtest does not expect them on the stubs' class-syntax TypedDicts.
The allowlist entry was only added in the py.typed change, but it is
needed from the commit that introduced the TypedDicts.

Assisted-by: ClaudeCode:claude-opus-5-5

* fix(typing): make strict mypy pass in the CI and pre-commit environments

The typing CI job and pre-commit run mypy with a different set of packages
installed than a development environment:

- setuptools_scm (build-time, used by _build_utils/gitversion.py) and
  importlib_metadata (test-only backport) are not installed in either, so
  they join the untyped optional dependencies whose missing imports are
  ignored.
- pre-commit also checks docs/conf.py, whose Mock.__getattr__ needed
  annotations under strict mode.
- pre-commit installs zarr, and tests/test_zarr3.py only imported the
  top-level package under TYPE_CHECKING, so zarr.codecs.numcodecs was
  not a known attribute. It now imports the submodule.

Assisted-by: ClaudeCode:claude-opus-5-5
Resolve the conflict in src/numcodecs/pickles.py by keeping the typed
signatures from zarr-developers#915 and the deprecation warning in Pickle.__init__.

Two tests added upstream construct the Pickle codec and now see the
deprecation warning: test_config_round_trip[pickle] (zarr-developers#906), which
rebuilds the codec from its config, and the static type test
test_pickle (zarr-developers#915). Both get a filterwarnings mark scoped to the
deprecation message.

Assisted-by: ClaudeCode:claude-opus-5.5
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.

1 participant