Skip to content

Restore running tests on Python 3.9 (oldest supported Python version) - #402

Open
Avasam (Avasam) wants to merge 1 commit into
microsoft:mainfrom
Avasam:Restore-running-tests-on-Python-3.9-oldest-supported-Python-version
Open

Avasam (Avasam) wants to merge 1 commit into
microsoft:mainfrom
Avasam:Restore-running-tests-on-Python-3.9-oldest-supported-Python-version

Conversation

@Avasam

@Avasam Avasam (Avasam) commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

As title says.
Done by force-installing a compatible-enough version of scipy-stubs. Conditions should make it easy to grep and remove once Python 3.9 support is dropped from PyLance stubs.

As other PRs, requires #397 first.


Alternatively, if maintainers make the call that 3.9 is no longer supported (due to being EOL, even 3.10 is EOL soon !), then I'll close this PR in favor of bumping the min-supported version in configs.

@Avasam
Avasam (Avasam) force-pushed the Restore-running-tests-on-Python-3.9-oldest-supported-Python-version branch from af4f91f to 51e5258 Compare September 21, 2026 19:55
@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.

@bschnurr

Copy link
Copy Markdown
Member

Result: ⚠️ needs-more-tests

Verification details

Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Summary: The sandbox only provided Python 3.13, and offline dependency setup was blocked by a missing `docopt-ng` wheel, so the Python 3.9 CI matrix could not be exercised. An ad-hoc check confirmed the dependency marker, workflow fallback, and both `run_tests.py` version branches. A mypy control passed, but the available unpinned mypy 2.3.1 cannot target Python 3.9. No tests were added for the new installer branch.

Test runs: 3 passed, 4 not run

  • ⚠️ Not run | Mypy Python 3.9 smoke test | python -m mypy tests/run_tests.py --python-version=3.9
  • ⚠️ Not run | Python 3.9 Pyright workflow test | python -m pyright
  • ⚠️ Not run | Stubtest workflow suite | python tests/run_stubtest.py
  • ⚠️ Not run | Offline dependency bootstrap | python -m venv --system-site-packages .venv && .venv/bin/python -m pip install --no-index --find-links="$PIP_FIND_LINKS" --group tests
  • ✅ Passed | Mypy Python 3.10 control | python -m mypy --version && python -m mypy tests/run_tests.py --python-version=3.10
  • ✅ Passed | Environment and test discovery | printf 'sandbox_profile=%s\n' "$AUTOMATION_SANDBOX_PROFILE"; printf '%s\n' '--- changed files ---'; git diff --name-status HEAD^ HEAD; printf '%s\n' '--- available Python/tooling ---'; command -v python3.9 || true; command -v python3.13 || true; command -v python || true; python --version 2>&1 || true; command -v uv || true; printf '%s\n' '--- environments/dependencies ---'; test -d .venv && echo '.venv present' || echo '.venv absent'; python - <<'PY'
    import importlib.util
    for name in ('pytest', 'mypy', 'pyright', 'scipy', 'scipy-stubs', 'optype'):
    print(f'{name}: {bool(importlib.util.find_spec(name))}')
    PY
    printf '%s\n' '--- test entrypoints ---'; find tests -maxdepth 2 -type f -print | sort
  • ✅ Passed | Python-version dependency fallback assertions | python - <<'PY'
    import importlib.util
    import pathlib
    import tomllib
    from packaging.requirements import Requirement
    root = pathlib.Path('.')
    data = tomllib.loads((root / 'pyproject.toml').read_text())
    tests = data['dependency-groups']['tests']
    scipy_req = next(Requirement(item) for item in tests if item.startswith('scipy-stubs'))
    assert not scipy_req.marker.evaluate({'python_version': '3.9'})
    assert scipy_req.marker.evaluate({'python_version': '3.10'})
    assert 'pip' in data['dependency-groups']['dev']
    workflow = (root / '.github/workflows/test.yml').read_text()
    assert 'python-version: ["3.9", "3.13"]' in workflow
    assert "if: ${{ matrix.python-version == '3.9' }}" in workflow
    assert "python -m pip install 'scipy-stubs<1.16' 'optype<0.10' --ignore-requires-python" in workflow
    spec = importlib.util.spec_from_file_location('run_tests_under_test', root / 'tests/run_tests.py')
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    original_version = module.sys.version_info
    try:
    calls = []
    module.subprocess.check_call = calls.append
    module.sys.version_info = (3, 9)
    module.install_requirements()
    assert calls[-1] == (module.sys.executable, '-m', 'pip', 'install', 'scipy-stubs<1.16', 'optype<0.10', '--ignore-requires-python')
    assert len(calls) == 3
    calls.clear()
    module.sys.version_info = (3, 10)
    module.install_requirements()
    assert len(calls) == 2
    finally:
    module.sys.version_info = original_version
    print('PASS: dependency marker, workflow Python 3.9 fallback, and run_tests version branches')
    PY
⚠️ Mypy Python 3.9 smoke test diagnostic output
mypy: error: argument --python-version: Python 3.9 is not supported (must be 3.10 or higher)
⚠️ Python 3.9 Pyright workflow test diagnostic output
Python 3.9 and pyright were unavailable after offline dependency setup failed.
⚠️ Stubtest workflow suite diagnostic output
Required runtime and stub dependencies could not be installed offline.
⚠️ Offline dependency bootstrap diagnostic output
Looking in links: /opt/python-wheelhouse, /opt/python-wheelhouse
ERROR: Could not find a version that satisfies the requirement docopt-ng
ERROR: No matching distribution found for docopt-ng

@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
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