Skip to content

Conversation

@mprib
Copy link
Owner

@mprib mprib commented Jan 10, 2026

Summary

Resolves #879 by fixing all basedpyright type checker errors.

Results: 363 errors → 0 errors across 6 phases

  • Phase 1: Critical data types (363→212 errors)
  • Phase 2: Core calibration (212→168 errors)
  • Phase 3: Trackers (168→131 errors)
  • Phase 4A: Controller and core files - assert guards, numpy type fixes
  • Phase 4B: Recording and triangulation - Optional params, cv2 stub ignores
  • Phase 4C: Managers and post-processing - tracker type fixes
  • Phase 4D: GUI and visualization - None guards, .to_numpy() for pandas
  • Phase 5: Test files - assertions before comparisons, pandas type fixes
  • Phase 6: Package init - PySide6 monkey-patch type ignores

Fix patterns used

  • assert x is not None for precondition violations (bugs)
  • if x is None: return for valid runtime states
  • .to_numpy() instead of .values for better pandas type inference
  • # type: ignore[code] with comments for library stub limitations
  • isinstance() assertions for runtime type narrowing

Test plan

  • uv run basedpyright - 0 errors
  • xvfb-run uv run pytest -n auto - 100 tests passed

Closes #879

mprib added 9 commits January 10, 2026 11:54
Add pandas-stubs for better DataFrame type inference.

Fix type errors in core data files:
- point_data.py: Numba type ignores, scipy butter signature
- point_data_bundle.py: Use field(init=False) for computed fields,
  @cached_property for caching, explicit type annotations
- persistence.py: Fix _list_to_array dtype signature, explicit None checks
- legacy_stereocal_paired_pose_network.py: Document normalized coordinate
  pattern for stereoCalibrate

Key patterns established:
- field(init=False) for computed dataclass fields
- @cached_property over manual object.__setattr__ caching
- Explicit None checks for type narrowing
- Well-documented type ignores for valid edge cases
- .to_numpy() over .values for better inference

Refs #879
- motion_trial: Add runtime arg inspection for tracker instantiation,
  fix dict type syntax, use getattr for optional wireframe
- reprojection: Add None guards for intrinsics, use np.zeros(5) for
  zero distortion instead of None
- intrinsic_calibrator: Guard against None frame_packet.points
- charuco: Use cv2.bitwise_not(), np.asarray() for MatLike conversion,
  fix getChessboardCorners typo
- capture_volume: Fix optional type annotations, add extrinsic guards
- quality_controller: Use .to_numpy(), handle empty arrays, add charuco guard

Refs #879
- Fix type annotation syntax in tracker.py (list[T], dict[K, V])
- Add return type to metarig_mapped property for override compatibility
- Use NDArray[Any] in PointPacket for flexible dtype support
- Add default args to get_points() across all trackers
- Add type ignores for incomplete mediapipe stubs
- Use cv2.bitwise_not() instead of ~ operator
- Add explicit None guards for tuple unpacking

Refs #879
- controller.py: Add assert guards for capture_volume access in methods
- export.py: Assert isinstance for pandas get_loc return type
- set_origin_functions.py: Use np.asarray() for OpenCV MatLike, rewrite mean_vec
- pose_network_builder.py: Cast numpy floats to Python floats
- paired_pose_network.py: Assert best_cameras_config not None
- synchronizer.py: Add early return guard for dropped frames
- recorded_stream.py: Add | None to optional params, assert for milestones
- video_recorder.py: Type ignore for cv2.VideoWriter_fourcc stubs
- packets.py: Change frame type to NDArray[Any] | None for flexibility
- sync_packet_triangulator.py: Add | None to optional camera_array param
- triangulation.py: Add | None to optional camera param
- post_processor.py: Type ignores for tracker_enum.value() calls
- blender_tools.py: Type annotation for pandas Series from np.sqrt
- intrinsic_stream_manager.py: Assert isinstance for CharucoTracker
- synchronized_stream_manager.py: Fix tracker.name access in conditional
- capture_volume_visualizer.py: Assert capture_volume exists, early return guards
- capture_volume_widget.py: Assert capture_volume after load
- camera_mesh.py: Assertions for matrix/rotation/translation, type ignore for QFont
- playback_triangulation_widget.py: Fix Path | None syntax, motion_trial guards
- post_processing_widget.py: Assertions for active_folder
- extrinsic_playback_widget.py: None guards for sync_packet and frame_packet
- log_widget.py: Fix message: str | None = None syntax
- intrinsic_calibration_dev_view.py: None check for frame
- frame_dictionary_emitter.py: Fix dict type annotation
- playback_frame_emitter.py: Conditional for tracker.get_connected_points()
- geometry_builders.py: Add matrix to guard, fix return type to dict[str, Any]
- playback_view_model.py: Use .to_numpy(), np.asarray() for isin
- test_calibration_equivalence.py: Assert translations not None before subtraction
- test_intrinsic_calibrator.py: Assert error not None, fix __main__ with TemporaryDirectory
- test_motion_trial.py: Assert tracker not None
- test_paired_pose_network.py: Fix possibly unbound variable in error handling
- test_persistence_roundtrip.py: Add loaded_cam assertions before array comparisons
- test_point_data.py: Type ignore for pandera.errors stub limitation
- test_point_data_bundle.py: Use .to_numpy() instead of .values, type ignores for .iloc
- test_pose_network_builder.py: Assert rotation/translation not None
- __init__.py: Type ignores for PySide6 monkey-patching (pyqtgraph compat)
@mprib mprib linked an issue Jan 10, 2026 that may be closed by this pull request
@mprib mprib merged commit 75313e4 into main Jan 10, 2026
9 checks passed
@mprib mprib deleted the 879-fix-type-checker-errors branch January 10, 2026 21:01
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.

Fix type checker errors

2 participants