Skip to content

ref: fix type annotations reported by pyright - #426

Merged
paulmueller merged 1 commit into
DC-analysis:mainfrom
paulmueller-agent:typing/pyright-annotations
Nov 19, 2026
Merged

paulmueller merged 1 commit into
DC-analysis:mainfrom
paulmueller-agent:typing/pyright-annotations

Conversation

@paulmueller-agent

Copy link
Copy Markdown
Contributor

Reduces the pyright errors from 323 to 205 without changing behavior.

RTDCWriter.h5file (~85 errors): the attribute was assigned from path_or_h5file, so pyright inferred str | Path | Group for it. It is now declared as h5py.Group, and the signature accepts h5py.Group (as documented) instead of h5py.File.

DiskStore.path (~25 errors): annotated as pathlib.Path | None; since None is a valid state (disk store disabled), the methods now use a private _store_path property that returns the path or raises the RuntimeError of assert_disk_store_path (which now uses it). In value_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 with if TYPE_CHECKING: ... else: try/except. Runtime behavior is unchanged.

Wrong annotations:

  • None defaults without | None: bg_off (get_bright_bc, get_bright_perc), emodulus and viscosity_out (scale_linear.convert)
  • npt.NDArray[bool] → npt.NDArray[np.bool_] (invalid type form)
  • return types: 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, Basin property overrides, stdlib method overrides, and Any-narrowing artifacts of the h5py stub.

🤖 Generated with Claude Code

- 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
paulmueller-agent force-pushed the typing/pyright-annotations branch from e712c4d to d6a2f6c Compare November 19, 2026 10:24
@paulmueller
paulmueller merged commit 55f3faa into DC-analysis:main Nov 19, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants