Pysam is a Python package for reading, manipulating, and writing genomics data such as SAM/BAM/CRAM and VCF/BCF files. It's a lightweight wrapper of the HTSlib API, the same one that powers samtools, bcftools, and tabix.
Python type checkers are not able to correctly infer the type of the object returned by pysam.AlignmentFile.pileup(...).__next__ (i.e. by IteratorColumn.__next__).
For example, mypy==1.10.1 infers it as AlignedSegment.
Observations
In libcalignmentfile.pyi:
from pysam.libcalignedsegment import AlignedSegment
The import pysam.libcalignedsegment.PileupColumn is missing.
The pysam.libcalignedsegment.PileupColumn class is used for typing in:
Summary
Python type checkers are not able to correctly infer the type of the object returned by
pysam.AlignmentFile.pileup(...).__next__
(i.e. byIteratorColumn.__next__
).For example,
mypy==1.10.1
infers it asAlignedSegment
.Observations
In
libcalignmentfile.pyi
:The import
pysam.libcalignedsegment.PileupColumn
is missing.The
pysam.libcalignedsegment.PileupColumn
class is used for typing in:Partial fix
Add the import in
libcalignmentfile.pyi
:Notes
Something is missing to completely fix this typing bug, as
mypy
continues to inferAlignedSegment
even after the previous partial fix.