Repository navigation
ref: fix type annotations reported by pyright - #426
Merged
paulmueller merged 1 commit intoNov 19, 2026
Merged
Conversation
- annotate `RTDCWriter.h5file` as h5py.Group (and accept h5py.Group in the signature, as documented) - annotate `DiskStore.path` as optional and use a private accessor that raises if the disk store path is not set - guard optional imports (boto3/botocore, nptdms) with TYPE_CHECKING - fix wrong annotations (None defaults, return types, NDArray[bool]) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
paulmueller-agent
force-pushed
the
typing/pyright-annotations
branch
from
November 19, 2026 10:24
e712c4d to
d6a2f6c
Compare
paulmueller
approved these changes
Nov 19, 2026
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.
Reduces the pyright errors from 323 to 205 without changing behavior.
RTDCWriter.h5file(~85 errors): the attribute was assigned frompath_or_h5file, so pyright inferredstr | Path | Groupfor it. It is now declared ash5py.Group, and the signature acceptsh5py.Group(as documented) instead ofh5py.File.DiskStore.path(~25 errors): annotated aspathlib.Path | None; sinceNoneis a valid state (disk store disabled), the methods now use a private_store_pathproperty that returns the path or raises theRuntimeErrorofassert_disk_store_path(which now uses it). Invalue_read, the data path is computed once.Optional dependencies (~10 "possibly unbound" errors): the optional imports of boto3/botocore (
fmt_s3) and nptdms plus the tdms column classes (fmt_tdms) are guarded withif TYPE_CHECKING: ... else: try/except. Runtime behavior is unchanged.Wrong annotations:
Nonedefaults without| None:bg_off(get_bright_bc,get_bright_perc),emodulusandviscosity_out(scale_linear.convert)npt.NDArray[bool]→npt.NDArray[np.bool_](invalid type form)cont_moments_cv→dict | None,get_pixelation_delta_pair→tuple[float | NDArray, float | NDArray],LazyContourList.__getitem__→NDArray | list[NDArray](slicing)Full test suite and the nitpicky docs build pass locally.
The remaining errors are mostly numpy typing details,
Basinproperty overrides, stdlib method overrides, and Any-narrowing artifacts of the h5py stub.🤖 Generated with Claude Code