chore: update pre-commit hook mypy#835
chore: update pre-commit hook mypy#835DimitriPapadopoulos wants to merge 1 commit intozarr-developers:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #835 +/- ##
===========================================
- Coverage 100.00% 98.89% -1.11%
===========================================
Files 27 27
Lines 901 901
===========================================
- Hits 901 891 -10
- Misses 0 10 +10 🚀 New features to boost your workflow:
|
| match="The numcodecs.zarr3 module is deprecated and will be removed in a future release of numcodecs. ", | ||
| ): | ||
| assert getattr(zarr3, codec_name) == getattr(zarr.codecs.numcodecs, codec_name) | ||
| assert getattr(zarr3, codec_name) == getattr(zarr.codecs.numcodecs, codec_name) # type: ignore[attr-defined] |
There was a problem hiding this comment.
why do we need a new type: ignore here? Is this improved type safety (if so, how?) or is this a regression in mypy
There was a problem hiding this comment.
I think this is a regression, but I often have a hard time understanding Python typing. The error can be seen in https://results.pre-commit.ci/run/github/68207196/1775503887.A9wQYmi0SzyJZg-CuQfz6A:
tests/test_zarr3.py:48: error: Module has no attribute "codecs"
I understand MyPy believes that the zarr>=3.1.3 module does not have a codecs submodule. I don't see why:
https://github.com/zarr-developers/zarr-python/tree/de947648e6ab6e7079ddb4f33b6b56070c3e6657/src/zarr/codecs
There was a problem hiding this comment.
if the only effect of this version bump is a new mypy bug to mitigate, then maybe we wait for 1.20.1 😅
There was a problem hiding this comment.
Let me find which exact version introduces this issue.
There was a problem hiding this comment.
Strange, I cannot reproduce this issue outside pre-commit, instead I get other similar and nonsensical error messages with MyPy ≥ 1.19.0:
$ uvx mypy@v1.18.2 tests
Success: no issues found in 39 source files
$
$ uvx mypy@v1.19.0 tests
tests/test_checksum32.py:19: error: Module has no attribute "util" [attr-defined]
tests/test_checksum32.py:20: error: Module has no attribute "util" [attr-defined]
Found 2 errors in 1 file (checked 39 source files)
$
$ uvx mypy@v1.20.0 tests
tests/test_checksum32.py:19: error: Module has no attribute "util" [attr-defined]
tests/test_checksum32.py:20: error: Module has no attribute "util" [attr-defined]
Found 2 errors in 1 file (checked 39 source files)
$ The module is importlib:
numcodecs/tests/test_checksum32.py
Lines 19 to 20 in 1fdde70
and of course
importlib does have the util submodule.
I fail to understand why MyPy emits different errors within pre-commit and outside pre-commit.
There was a problem hiding this comment.
Meanwhile, let's bump to 1.18.2.
There was a problem hiding this comment.
It's easy to fix for MyPy ≥ 1.19.0:
- import zarr.
+ import zarr.codecsNot sure it makes sense, but it doesn't hurt.
I still fail to understand why MyPy emits different errors within pre-commit and outside pre-commit.
4927b1c to
c167ad2
Compare
updates: - github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.20.0 Also enforce consistent indentation in the YAML config file.
c167ad2 to
53c3e5e
Compare
updates:
v1.20.0v1.18.2TODO: