Skip to content

Comments

Generate typing stubs with docstub#7546

Closed
lagru wants to merge 10 commits intoscikit-image:mainfrom
lagru:docstub-demo
Closed

Generate typing stubs with docstub#7546
lagru wants to merge 10 commits intoscikit-image:mainfrom
lagru:docstub-demo

Conversation

@lagru
Copy link
Member

@lagru lagru commented Sep 17, 2024

Description

It's very early days, but this WIP will help keep track of progress on how docstub works in conjunction with scikit-image.

Roadmap:

  • Conform skimage's docstrings to grammar / extend docstubs grammar
    • skimage.<submodule> ...
  • Verify generated stubs with mypy (or similar)

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 added the 🤖 type: Infrastructure CI, packaging, tools and automation label Sep 17, 2024
@lagru lagru changed the title Generating typing stubs with docstub Generate typing stubs with docstub Sep 18, 2024
Copy link
Member

@mkcor mkcor left a comment

Choose a reason for hiding this comment

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

Happy to mark this as 'ready for review,' so we can move forward and continue the work in subsequent PRs.

Returns
-------
out : 2-D array (same dtype as input image)
out : 2-D array, same dtype as input image
Copy link
Member

Choose a reason for hiding this comment

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

Is there any consensus/convention on '2-D' vs '2D' and 'array' vs 'ndarray?'

If so, I'll update #7518 accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for the late reply. I don't think there's a solid convention. But intuitively I'd say "ndarray" usually implies a true NumPy array while "array" just implies an object that is an instance of a NumPy array or implements the array API. That said, in context of our library that doesn't yet make a huge difference.

I'd go with "array" personally and "array-like" for everything that we expect to be coercible into a (NumPy) array.

Copy link
Member

Choose a reason for hiding this comment

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

All good! Not sure I get the difference between a 'true NumPy array' and 'an instance of a NumPy array' but I agree with the choice: "array" for an actual (NumPy) array and "array-like" for anything coercible into a (NumPy) array.

lagru added 3 commits April 21, 2025 17:52
Other change is required by pre-commit hooks.
Copies over the setup from docstub. Obviously this will throw a
bazillion errors. But still useful to have this in place already.


def walk_dir(root):
"""Walk each directory and file in the file tree of `root`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""Walk each directory and file in the file tree of `root`.
"""Walk recursively the contents (directories and files) of `root`.

logger.info("creating empty __init__.py in root dir")
(dst / "__init__.py").touch()

# Copy tests/ directories to dst, while emulating the sub dir structure
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Copy tests/ directories to dst, while emulating the sub dir structure
# Copy tests/ subdirectories to dst, while emulating the tree structure

@lagru
Copy link
Member Author

lagru commented May 25, 2025

Closing this in favor of a more granular / step-by-step approach in #7802.

@lagru lagru closed this May 25, 2025
@lagru lagru deleted the docstub-demo branch May 25, 2025 18:13
@lagru lagru added the 🧩 typing Type annotations, type checking, and stubs label May 25, 2025
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: Infrastructure CI, packaging, tools and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants