Skip to content

Resolve F401 TODO for __init__.pyi - #400

Open
Avasam (Avasam) wants to merge 2 commits into
microsoft:mainfrom
Avasam:Resolve-`F401`-TODO-for-`__init__.pyi`
Open

Avasam (Avasam) wants to merge 2 commits into
microsoft:mainfrom
Avasam:Resolve-`F401`-TODO-for-`__init__.pyi`

Conversation

@Avasam

@Avasam Avasam (Avasam) commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Removes unused imports from __init__.pyi that are not meant as re-exports.
Removes unnecessary explicit re-exports when __all__ is present in affected files.

@bschnurr

Bill Schnurr (bschnurr) commented Sep 21, 2026

Copy link
Copy Markdown
Member

🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR.

from packaging.version import parse as parse_version

from . import _docstring, _version, cbook, colors as colors, rcsetup
from ._typing import *

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.

Warning · Non-blocking recommendation

Could you confirm that matplotlib.colors, matplotlib.cbook, and matplotlib.rcsetup are not supported package-level runtime attributes before removing these explicit re-exports? Normal usage such as import matplotlib; matplotlib.colors.Normalize(...) would otherwise lose type support; please restore any runtime-exposed modules and add a regression case.

@Avasam Avasam (Avasam) Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kept colors just because of that one explicit example in docs. https://matplotlib.org/stable/users/explain/colors/colormapnorms.html#colormap-normalization

import matplotlib as mpl
norm = mpl.colors.Normalize(vmin=-1, vmax=1)

But even matplotlib's own pyi (as of 3.8.0+, these stubs are explictly for 3.7.5) shows these were not meant for explicit re-export:
https://github.com/matplotlib/matplotlib/blob/615ff27caeeeb4934bf9164c51c92706a1cc95a0/lib/matplotlib/__init__.pyi#L1-L32

@bschnurr

Copy link
Copy Markdown
Member

Result: 🔴 could-not-verify

Verification details

Verification: Isolated verification observed failures that were not classified as caused by this PR: Sandbox dependency and test discovery. The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Summary: Verification could not begin because the disposable container failed to start with a temporary-directory `PermissionError`. Consequently, the targeted Ruff, type-checker, and stubtest checks were not run. The PR adds no tests, and confidence is limited entirely by the environment failure.

Test runs: 1 failed, 2 not run

  • ⚠️ Not run | Ruff checks for changed stubs | python -m ruff check stubs/matplotlib/init.pyi stubs/sklearn/__check_build/init.pyi stubs/sklearn/__check_build/_check_build.pyi stubs/sklearn/utils/init.pyi stubs/sympy-stubs/init.pyi stubs/sympy-stubs/series/init.pyi stubs/sympy-stubs/sets/init.pyi stubs/sympy-stubs/solvers/init.pyi stubs/sympy-stubs/utilities/mathml/init.pyi stubs/vispy/glsl/init.pyi stubs/vispy/io/init.pyi
  • ⚠️ Not run | Affected package stubtests | python tests/run_stubtest.py sklearn sympy-stubs vispy
  • Failed | unrelated to this PR | Sandbox dependency and test discovery | printf 'PROFILE=%s\n' "$AUTOMATION_SANDBOX_PROFILE"; printf '%s\n' '--- changed files ---'; git diff --name-status HEAD^ HEAD; printf '%s\n' '--- dependency state ---'; command -v uv || true; command -v python || true; test -d .venv && echo '.venv present' || echo '.venv absent'; printf '%s\n' '--- test runners ---'; sed -n '1,240p' tests/run_hygiene.py; sed -n '1,260p' tests/run_tests.py; sed -n '1,260p' tests/run_stubtest.py; printf '%s\n' '--- changed/new tests ---'; git diff --name-only HEAD^ HEAD -- tests
⚠️ Ruff checks for changed stubs diagnostic output
Container startup failed before dependency discovery or test execution.
⚠️ Affected package stubtests diagnostic output
Container startup failed before dependency discovery or test execution.
Sandbox dependency and test discovery diagnostic output
PermissionError: [WinError 32] The process cannot access the temporary automation directory because it is being used by another process.

@bschnurr Bill Schnurr (bschnurr) left a comment

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.

Approved via Review Center.

@bschnurr Bill Schnurr (bschnurr) added the review-auto:approved Automated review: no blocking findings (approval posted). label Sep 21, 2026
from packaging.version import parse as parse_version
from matplotlib import (
colors as colors, # Example usage: https://matplotlib.org/stable/users/explain/colors/colormapnorms.html#colormap-normalization
)

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.

Warning · Non-blocking recommendation

📍 stubs/matplotlib/init.pyi:5
The prior export-parity concern is only partially addressed: colors is restored, but normal package-level access to matplotlib.cbook and matplotlib.rcsetup remains untyped. Verify those runtime attributes and restore their explicit re-exports when supported, with regression coverage for package-qualified access.

[verified]

@bschnurr

Copy link
Copy Markdown
Member

Result: ⚠️ partially-verified

Verification details

Verification: Isolated verification observed failures whose relationship to this PR could not be determined: Mypy validation of affected stubs; this review is not fully verified. Isolated verification observed failures that were not classified as caused by this PR: Changed-file Ruff check.

Summary: Ruff’s targeted F401 check passed across all stubs, and all nine changed stub files passed formatting. A broader Ruff command failed only on deleted paths and diagnostics confirmed in the base branch. Mypy could not complete because required NumPy/SciPy dependencies were unavailable; Pyright and stubtest were likewise unavailable offline. No PR-specific failure was established, so verification is partial.

Test runs: 3 passed, 2 failed, 2 not run

  • Failed | unrelated to this PR | Changed-file Ruff check | python -m ruff check pyproject.toml stubs/matplotlib/init.pyi stubs/sklearn/__check_build/init.pyi stubs/sklearn/__check_build/_check_build.pyi stubs/sklearn/utils/init.pyi stubs/sympy-stubs/init.pyi stubs/sympy-stubs/series/init.pyi stubs/sympy-stubs/sets/init.pyi stubs/sympy-stubs/solvers/init.pyi stubs/sympy-stubs/utilities/mathml/init.pyi stubs/vispy/glsl/init.pyi stubs/vispy/io/init.pyi
  • Failed | relationship unknown | Mypy validation of affected stubs | python -m mypy stubs/matplotlib/init.pyi stubs/sklearn/utils/init.pyi stubs/sympy-stubs/init.pyi stubs/sympy-stubs/series/init.pyi stubs/sympy-stubs/sets/init.pyi stubs/sympy-stubs/solvers/init.pyi stubs/sympy-stubs/utilities/mathml/init.pyi stubs/vispy/glsl/init.pyi stubs/vispy/io/init.pyi
  • ⚠️ Not run | Pyright validation | python -m pyright
  • ⚠️ Not run | Affected-package stubtest | python tests/run_stubtest.py sklearn-stubs sympy-stubs vispy-stubs
  • Passed | Repository F401 validation | python -m ruff check --select F401 stubs
  • Passed | Changed-file Ruff formatting | python -m ruff format --check pyproject.toml stubs/matplotlib/init.pyi stubs/sklearn/utils/init.pyi stubs/sympy-stubs/init.pyi stubs/sympy-stubs/series/init.pyi stubs/sympy-stubs/sets/init.pyi stubs/sympy-stubs/solvers/init.pyi stubs/sympy-stubs/utilities/mathml/init.pyi stubs/vispy/glsl/init.pyi stubs/vispy/io/init.pyi
  • Passed | Environment and test discovery | printf 'SANDBOX_PROFILE=%s\n' "${AUTOMATION_SANDBOX_PROFILE:-}"; printf '%s\n' '--- refs ---'; git branch -a; printf '%s\n' '--- changed files vs first available protected base ---'; base=''; for ref in origin/main origin/master upstream/main upstream/master; do if git rev-parse --verify "$ref" >/dev/null 2>&1; then base=$(git merge-base HEAD "$ref"); echo "base_ref=$ref base_sha=$base"; break; fi; done; if [ -n "$base" ]; then git diff --name-status "$base" HEAD; else git diff-tree --no-commit-id --name-status -r HEAD; fi; printf '%s\n' '--- dependency and runner availability ---'; command -v uv || true; command -v python || true; python --version; [ -f uv.lock ] && echo 'uv.lock=yes' || echo 'uv.lock=no'; [ -d .venv ] && echo '.venv=yes' || echo '.venv=no'; python - <<'PY'
    import importlib.util
    for name in ('ruff','mypy','pyright','pytest','sklearn','sympy','vispy','matplotlib'):
    print(f'{name}={bool(importlib.util.find_spec(name))}')
    PY
    printf '%s\n' '--- test files changed ---'; if [ -n "$base" ]; then git diff --name-only "$base" HEAD -- 'tests/**' 'test' || true; fi
Changed-file Ruff check diagnostic output
E902: the two deleted sklearn/__check_build files do not exist. Ruff also reported seven RUF036 diagnostics in sklearn/utils and a duplicate Reals entry in sympy sets; these lines are unchanged from origin/main.
Mypy validation of affected stubs diagnostic output
Mypy reported missing dependencies, beginning with: Cannot find implementation or library stub for module named "numpy" and Library stubs not installed for "scipy.sparse".
⚠️ Pyright validation diagnostic output
Discovery found pyright unavailable. The repository has no lockfile permitting an offline dependency bootstrap.
⚠️ Affected-package stubtest diagnostic output
The required sklearn, sympy, and vispy runtime packages were unavailable, with no locked offline installation path.

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

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants