Skip to content

chore(mypy): remove the no-op strict = false override - #486

Draft
d-v-b wants to merge 6 commits into
mainfrom
chore/remove-noop-mypy-strict-override
Draft

d-v-b wants to merge 6 commits into
mainfrom
chore/remove-noop-mypy-strict-override

Conversation

@d-v-b

@d-v-b d-v-b commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Removes the [[tool.mypy.overrides]] block that sets strict = false for 14 module entries, because mypy ignores strict = false in a per-module override. Type checking is unchanged: those modules were already checked strictly, and they still pass.

It also fixes the one mypy error in tests/test_store/test_fsspec.py and takes that module off the ignore_errors list.

CI fix, unrelated to the change above: numcodecs main now warns that its Pickle codec is deprecated, which fails the pickle decode-gate tests in tests/test_v2.py in the py=3.15-upstream job. This affects every branch, not only this one. 711a47b adds a filter that ignores that warning for just those tests.

Evidence
  • mypy source. mypy/config_parser.py (2.4.1, the version pinned in pyproject.toml and uv.lock) handles the key like this: if key == "strict": if v: set_strict_flags(); continue. A false value is dropped without a warning. The same guard is in v1.0.0 and v1.15.0. strict can't be scoped to a module in either direction: set_strict_flags (mypy/main.py:1470-1474) writes to the global options, so strict = true in an override would turn strict mode on for the whole run.
  • Probes on main's config. The agent added deliberately untyped functions to tests/test_metadata/test_v3.py, src/zarr/testing/stateful.py, tests/test_store/test_wrapper.py and tests/package_with_entrypoint/__init__.py, all covered by the removed block. mypy flagged all four.
  • Reviewer's wider probe. Probes for 11 strict-implied settings plus three extra error codes, in five files covered by the block, produce identical output with and without it (70 errors both ways). As a control, replacing strict = false with the explicit flags set to false cuts that to 20 errors. So the module patterns did match those files; the block just carried no flags.
  • History. Fix some mypy errors zarr-developers/zarr-python#3044 (May 2025) added the block as a "partially fixed" tier between ignore_errors and full strictness. Later PRs moved more modules into it, through 2025. The tier never took effect, so each module has been fully strict since it was moved in.
  • Other readers. sp-repo-review only checks top-level tool.mypy keys, and the zarr-http-server mypy job uses its own package config.
  • The rest of the config. The TODO above the ignore_errors list pointed at the removed tier. It now says to fix those modules' errors and take them off the list. All six entries there still have real errors.
Adversarial review record
  • Round 1 (fresh reviewer, given only the diff and the files): nothing serious.
    • Nit: the commit message said "14 modules", but two entries are globs that cover 8 modules between them. Fixed by rewording the commit before pushing.
    • Nit: record the intent behind Fix some mypy errors zarr-developers/zarr-python#3044. Done in this description.
    • Minor, suggested follow-up: tests.test_store.test_fsspec has one remaining mypy error (union-attr at line 492), so it could leave the ignore_errors list. mypy also accepts per-module strict without a warning, so a check that rejects strict inside overrides would stop this from coming back. Neither is done here.
  • Round 2 (a second fresh reviewer, checking the diff, the commit message and this description): nothing serious.
    • Minor: the description implied strict = true could fix the block. Fixed above: strict sets global options, so it can't be scoped to a module.
    • Minor: "fully strict since then" implied all 14 entries joined in Fix some mypy errors zarr-developers/zarr-python#3044. Fixed above: modules joined at different times.
    • Nit: a sentence about pyright not reading [tool.mypy] said nothing. Removed.
    • Nit: this record pointed to a later comment. Filled in here instead.
    • Nit: the Assisted-by trailer spells the model ID with hyphens. Kept, because that is the model's ID.
  • The review stopped after two rounds in a row with nothing serious.
  • test_fsspec commit (one round by a fresh reviewer, given only that commit and the files it touches): nothing serious.
    • Confirmed: on the parent commit, with the module off the ignore list, mypy reports exactly one error (union-attr at line 492), and the isinstance narrowing clears it. from zarr import AsyncGroup is the class that getitem returns. The test still fails if getitem returns an array, now with a clearer assertion error.
    • Follow-up (ec7e3e8, at the maintainer's suggestion): the test now calls AsyncGroup.get_group, which returns an AsyncGroup and raises ContainsArrayError for an array, instead of narrowing getitem's result with an isinstance assert. get_group goes through getitem internally, so the test exercises the same lookup.
    • Minor: fsspec, s3fs and botocore resolve to Any, because of pytest.importorskip and missing py.typed. So strict checking covers the module's own code and its zarr calls, not those libraries' calls. Fixed by rewording the commit message to say so. CI's mypy run uses the same locked environment as local runs.

🤖 Generated with Claude Code

d-v-b added 2 commits December 1, 2026 09:48
mypy applies `strict` only when it is true, so `strict = false` in a
per-module override is ignored. The 14 entries listed there (modules and
globs) were already checked strictly. Remove the block, and reword the
TODO on the `ignore_errors` list that pointed at it.

Assisted-by: ClaudeCode:claude-opus-5-5
Narrow the subgroup returned by `AsyncGroup.getitem` to `AsyncGroup`
before calling `group_keys`, which was the module's only mypy error, and
remove `tests.test_store.test_fsspec` from the `ignore_errors` list so the
module's own code is type-checked like the rest of the tests.

Assisted-by: ClaudeCode:claude-opus-5-5
d-v-b added 2 commits December 1, 2026 11:08
numcodecs main now warns that its Pickle codec is deprecated whenever one
is created, and the suite turns warnings into errors, so the pickle
decode-gate tests in test_v2.py fail in the upstream-dependencies job.
Those tests create Pickle codecs on purpose, so ignore that warning for
them. Released numcodecs doesn't warn, so the filter ignores the warning
rather than requiring it.

Assisted-by: ClaudeCode:claude-opus-5-5
`AsyncGroup.get_group` returns an `AsyncGroup` and raises if the member is
an array, so the test needs no isinstance assert to type-check.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant