Skip to content

Fix simple errors reported by docstub (I)#7853

Merged
lagru merged 10 commits intoscikit-image:mainfrom
lagru:simple-docstub-fixes
Jul 23, 2025
Merged

Fix simple errors reported by docstub (I)#7853
lagru merged 10 commits intoscikit-image:mainfrom
lagru:simple-docstub-fixes

Conversation

@lagru
Copy link
Copy Markdown
Member

@lagru lagru commented Jul 16, 2025

Description

There will be follow up PRs but I'd like to keep them at a manageable review size. Let me know if follow PRs should be bigger or smaller.

Reviewing commit by commit isn't a bad idea, since that groups similar fixes together.

Checklist

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

...

@lagru lagru requested a review from mkcor July 16, 2025 20:30
@lagru lagru added 📄 type: Documentation Updates, fixes and additions to documentation 🧩 typing Type annotations, type checking, and stubs labels Jul 16, 2025
lagru added 3 commits July 16, 2025 22:45
In the case of `denoisy_wavelet` and and active contour the literal list
would have gotten quite long, so I'm opting for "str" for now. Later we
could provide a more precise type as an inline annotation if we wanted.
@lagru lagru marked this pull request as ready for review July 16, 2025 20:57
@lagru lagru added 🔧 type: Maintenance Refactoring and maintenance of internals and removed 📄 type: Documentation Updates, fixes and additions to documentation labels Jul 16, 2025
Offset added to the footprint center point. Shift is bounded to the
footprint sizes (center must be inside the given footprint).
p0, p1 : float in [0, ..., 1]
p0, p1 : float, optional, in interval [0, 1]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would be nice to be able to spell this as float in interval [0, 1], optional

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, with some modification of docstub's grammar this would be totally doable. We'd have to come up with a consistent expectation. E.g.

interval: qualname "in interval" INTERVAL_BRACE number "," number INTERVAL_BRACE

INTERVAL_BRACE: "[" | "]" | "(" | ")"

might work. We could also support "in range". What I don't like is that we have to hardcode the "in interval" string. Otherwise it could be potentially confused with other expressions in the grammar.

There's a cost to doing this. Python's type system doesn't support this (yet, as far as I know). Docstub could either drop it or encode it with typing.Annotated.

Maybe another solution might make this more readable? E.g. the docstub expects the following form

name : annotation, optional, extra_info

Maybe we could allow switching "optional" and "extra_info" around. That way one could write

 p0, p1 : float, in interval [0, 1], optional

Doesn't feel like an immediate priority though. Curious what you think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Created scientific-python/docstub#65 to continue / preserve this discussion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, as long as optional is last, I think that reads fine. Optional is not super helpful, since it's already encoded in the function signature.

Could also use float in [0, 1]

Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
@lagru lagru merged commit f7a9fbb into scikit-image:main Jul 23, 2025
25 checks passed
@lagru lagru deleted the simple-docstub-fixes branch July 23, 2025 21:55
@stefanv stefanv added this to the 0.26 milestone Jul 23, 2025
@mkcor
Copy link
Copy Markdown
Member

mkcor commented Aug 2, 2025

There will be follow-up PRs but I'd like to keep them at a manageable review size. Let me know if follow PRs should be bigger or smaller.

Neither bigger nor smaller! I find this size to be the maximum manageable one for an effective review.

Reviewing commit by commit isn't a bad idea, since that groups similar fixes together.

Thanks for the reminder, the commit breakdown is indeed helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🧩 typing Type annotations, type checking, and stubs 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants