Skip to content

[sklearn]: use npt.NDArray instead of np.ndarray#388

Open
hoel-bagard wants to merge 1 commit into
microsoft:mainfrom
hoel-bagard:main
Open

[sklearn]: use npt.NDArray instead of np.ndarray#388
hoel-bagard wants to merge 1 commit into
microsoft:mainfrom
hoel-bagard:main

Conversation

@hoel-bagard
Copy link
Copy Markdown

This PR changes some of the sklearn stubs to use npt.NDArray[Any] instead of np.ndarray. This avoids pyright raising reportUnknownMemberType errors.

If this change is accepted, I can modify the rest of the stubs for consistency.

@hoel-bagard
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates scikit-learn stubs to prefer a numpy.typing-based array type (npt.NDArray[Any]) over np.ndarray, aiming to reduce Pyright reportUnknownMemberType noise and make array typing more consistent across the sklearn stubs.

Changes:

  • Added a shared NDArray type alias (npt.NDArray[Any]) in stubs/sklearn/_typing.pyi.
  • Updated MatrixLike to use the new NDArray alias instead of np.ndarray.
  • Switched several return/attribute annotations in stubs/sklearn/linear_model/_base.pyi from numpy.ndarray to NDArray.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
stubs/sklearn/linear_model/_base.pyi Replaces ndarray return/attribute types with the shared NDArray alias.
stubs/sklearn/_typing.pyi Introduces NDArray = npt.NDArray[Any] and updates MatrixLike to use it.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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