Repository navigation
Conversation
Hoeze
force-pushed
the
build/mypy-strict
branch
from
October 17, 2026 00:19
8213851 to
161706c
Compare
Hoeze
force-pushed
the
build/mypy-strict
branch
2 times, most recently
from
October 17, 2026 16:22
8bde764 to
cf34749
Compare
mypy skipped the bodies of functions without annotations, and ignore_missing_imports hid every package without types. Strict mode needs annotations everywhere. pyfaidx, polars-bio and Biopython ship no types, so an override ignores only their imports. mypy sees the results of polars_bio.scan_vcf and polars_bio.overlap as Any, so they get the annotation LazyFrame.
_resize_bounds gets the anchor after Interval.resize, pad or trim checked it. VariantSeqExtractor._split takes keep as "left", "right" or "both".
Type checkers read the annotations of kipoiseq2. __all__ lists the names that kipoiseq2 re-exports: Interval, Variant, Alphabet, the presets AMINO_ACIDS, DNA and RNA, Encoder and Tokenizer. Strict mypy rejects `from kipoiseq2 import Encoder` otherwise. So `from kipoiseq2 import *` binds only these names, extractors and transforms.
Interval takes start and end as typing.SupportsIndex instead of int, and Variant takes pos as SupportsIndex. So strict mypy accepts numpy integers there, as the runtime and test_interval_numpy_integers already did. The fields stay int. A bool still raises a TypeError at runtime, although SupportsIndex accepts it. The method parameters stay int.
Hoeze
force-pushed
the
build/mypy-strict
branch
from
October 17, 2026 17:19
cf34749 to
9e43fba
Compare
This branch has not been deployed
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.
tl;dr: kipoiseq2 ships a
py.typedmarker, so type checkers read its annotations. mypy checks the package in strict mode, so every function needs annotations.The wheel and the sdist contain
kipoiseq2/py.typed.kipoiseq2/__init__.pylistsInterval,Variant,Alphabet,AMINO_ACIDS,DNA,RNA,Encoder,Tokenizer,extractorsandtransformsin__all__. Without__all__, strict mypy rejectsfrom kipoiseq2 import Interval, Variant, the import in README.md, because strict mode does not re-export imported names.from kipoiseq2 import *now binds only these ten names.pyproject.tomlsetsstrict = truefor mypy. Before, mypy skipped the bodies of functions without annotations, andignore_missing_imports = truehid every package without types. Now an override ignores only the missing types of pyfaidx, polars-bio and Biopython. Thetypechecktox env still runsmypy src/kipoiseq2.Strict mode needed few changes.
_import_polarsand_check_namesinkipoiseq2.extractorsget annotations. mypy sees the results ofpolars_bio.scan_vcfandpolars_bio.overlapasAny, so they get the annotationLazyFrame.Some annotations are more precise:
IntervalandVarianttake the positions astyping.SupportsIndex, so strict mypy accepts numpy integers, as the runtime did already._resize_boundstakes the anchor asLiteral["start", "center", "end"], andVariantSeqExtractor._splittakeskeepasLiteral["left", "right", "both"].mypy does not check the tests. About 60 test calls pass wrong types on purpose, to test the runtime checks, e.g. a float as
Interval.shift(offset)or a positionaluse_strand. Each of them would need a# type: ignore.