Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
==========================================
- Coverage 95.11% 93.70% -1.42%
==========================================
Files 1 1
Lines 635 635
==========================================
- Hits 604 595 -9
- Misses 31 40 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rgaudin
approved these changes
Oct 26, 2026
rgaudin
left a comment
Member
There was a problem hiding this comment.
LGTM ; good catch (didn't review the script)
…ution SuggestionSearch and SuggestionResultSet were declared in the type stubs but not exported by libzim.suggestion at runtime, so importing them failed. create_module reused its name argument as loop variable, so each submodule was also registered in sys.modules under its last member name (e.g. sys.modules['Searcher']).
- set_cluster_cache_max_size parameter is size_in_bytes, not nb_clusters - IllustrationInfo accepts extra_attributes=None - declare enum members with values so type checkers see them as members - declare __all__ and mark Cython extension classes as disjoint bases - fix .pyx annotations: implicit Optional, and config methods returning Self
- mypy.stubtest checks names, parameters and defaults - check_stub_annotations compares stubs annotations with the ones Cython keeps on compiled functions, which stubtest does not check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
.pyistubs are hand-written and drift fromlibzim.pyxunnoticed (see the staleCreator.add_metadatastub fixed in #285). This adds two checks to QA (also part ofinv checkall):inv check-stubtest:mypy.stubtestcompares the stubs with the compiled module: missing/extra objects, parameter names, kinds and defaults. pyright has no equivalent (it never imports the runtime module); mypy is only used as stubtest engine, pyright stays the type checker.inv check-stub-annotations: stubtest does not compare annotation types, but Cython keeps the.pyxannotations on compiled functions (__annotations__).scripts/check_stub_annotations.pycompares them with the stubs ones, after normalizing equivalent spellings (pathlib.Path/Path,pyint/int,Self, forward references, exported aliases likeWritingBlob/Blob,Generatordefault parameters). Annotations missing on either side are ignored. It reports the Upgrade dependencies #285add_metadatadrift when run against the old stub.Known blind spot: constructors of Cython extension types take their arguments in
__cinit__, and their runtime__init__is a slot wrapper with an(self, /, *args, **kwargs)signature, so neither check can verify constructor signatures. Those are allowlisted inscripts/stubtest-allowlist.txt(with Cython auto-generated pickling methods); constructor stubs stay covered by tests, which are type-checked by pyright.Drifts found and fixed:
libzim.suggestiondid not exportSuggestionSearchandSuggestionResultSetat runtime, while stubs declared them (from libzim.suggestion import SuggestionSearchpassed type checking but raisedImportError)reader.set_cluster_cache_max_sizeparameter issize_in_bytesat runtime,nb_clustersin the stubIllustrationInfo(extra_attributes=None)is accepted at runtime, but stub saidMapping[str, str] = {}; the stub now mirrors the runtime structure (NamedTuple base +__new__) so the attribute stays typed as neverNonename: Self, which type checkers no longer treat as members.pyxannotations: implicit Optional (width: pyint = None) andCreator.config_*()annotated as returning_Creatorinstead ofSelf__all__and mark Cython extension classes with@disjoint_base(PEP 800, imported fromtyping_extensionsin stubs only)Tests added for each runtime-visible fix (they fail at runtime, or under pyright, before this change).
Unrelated bug fixed on the way:
create_modulereused itsnameargument as loop variable, so each submodule was also registered insys.modulesunder its last member name (sys.modules["Searcher"],sys.modules["SuggestionSearcher"], ...).