Skip to content

Fix type hints for modify_in_place overloads in Dataset#171

Merged
gvarnavi merged 1 commit intodevfrom
fix/dataset-type-hints
Feb 4, 2026
Merged

Fix type hints for modify_in_place overloads in Dataset#171
gvarnavi merged 1 commit intodevfrom
fix/dataset-type-hints

Conversation

@arthurmccray
Copy link
Collaborator

This PR fixes type hints for Dataset, specifically to do with the overloading of Dataset.crop() and Dataset.bin() and modify_in_place:bool.

Previously, .crop() -> Dataset no matter what, leading to issues:

image

Now with the fix, everything works as expected.
image

There are 2 other main types of change in the file:

  • changing np.isscalar(val) to isinstance(val, float|int) which is better handled by static type checkers
  • ruff reformatted dataset.py in a few places due to line lengths--not sure why that hadn't happened previously

Also, I'm not quite sure why, but reveal_type from typing was actually working okay even with the old version... and this fix doesn't break it or anything so there's no problems there.

@arthurmccray arthurmccray requested a review from gvarnavi February 3, 2026 23:00
@arthurmccray
Copy link
Collaborator Author

@gvarnavi let me know if this makes sense to you as i know you've played with static type checkers quite a bit.

Copy link
Collaborator

@gvarnavi gvarnavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, and makes my type-hinter happy!

@gvarnavi gvarnavi merged commit 38367e7 into dev Feb 4, 2026
4 checks passed
@arthurmccray arthurmccray deleted the fix/dataset-type-hints branch February 5, 2026 16:35
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