Skip to content

Only enable Memray options when the pytest plugin is installed - #5307

Merged
illia-v merged 3 commits into
urllib3:mainfrom
00200200:codex/ci-memray-plugin-availability
Oct 14, 2026
Merged

illia-v merged 3 commits into
urllib3:mainfrom
00200200:codex/ci-memray-plugin-availability

Conversation

@00200200

Copy link
Copy Markdown
Contributor

The Python 3.15 and brotlipy jobs in CI run 38137864167 stop before collecting tests with unrecognized arguments: --memray --hide-memray-summary.

dev-base excludes pytest-memray when python_full_version >= '3.15', but tests_impl() enables its CLI options for final, GIL-enabled CPython on non-Windows platforms without checking whether the plugin was installed. The same noxfile blob is present on current main (5ebe9bf9f691646dcabdb259ffabfc6108ded5e8) and the failing run's head.

Check importlib.util.find_spec('pytest_memray') in the session's interpreter after installing dependencies, before adding Memray options. Keep the existing implementation, release-level, free-threading and Windows restrictions. This follows the installed dependency selection without duplicating its Python version ceiling. Coverage invocation, settings and thresholds are unchanged.

Validation on macOS:

  • Before the fix, a mock Nox session with final CPython and no plugin executed the generated coverage/pytest command against a real smoke test: pytest exited 4 with the same unrecognized arguments. After the fix, it exited 0.
  • Six mock-session cases passed: missing plugin, installed plugin, prerelease, free-threaded CPython, PyPy and Windows. Assertions also checked both Memray flags and retention of the coverage command/environment.
  • uvx nox -s test-3.14 -- test/test_util.py: 595 passed, 6 skipped, with pytest-memray installed and enabled.
  • After removing pytest-memray and memray from that disposable environment, uvx nox -r --no-install -s test-3.14 -- test/test_util.py: 595 passed, 6 skipped, with neither Memray option passed.
  • uvx nox -s test-3.15 -- test/test_util.py: 595 passed, 6 skipped on Python 3.15.0rc2.
  • uvx nox -P 3.15 -s test_brotlipy -- test/test_response.py -k brotli: 3 passed, 13 skipped, 211 deselected on Python 3.15.0rc2 (the normal warning about brotlipy lacking decompression-bomb protection was emitted).
  • Black, flake8 (including flake8-2020), isort, git diff --check, and targeted mypy -m noxfile passed.
  • The full uvx nox -s mypy command failed on an unchanged annotation in src/urllib3/connection.py:150 (Final can be only used as an outermost qualifier).

Limits: no full test suite, aggregated coverage check, or Linux Python 3.15 final run was performed locally. The final-release missing-plugin branch was exercised with a mock session and real pytest; the available local Python 3.15 interpreter is an RC. The regression harness was temporary, not added to the repository's test suite.

Checked open PRs/issues for Memray, Python 3.15, brotlipy and the unrecognized-arguments error. The Memray search hits (#5226, #5237, #5162) do not change this gating; #5263 retains it. No duplicate fix was found.

This change and its validation were prepared with OpenAI Codex assistance. It is independent of #5286 and changes no timeout behavior.

illia-v
illia-v previously approved these changes Oct 14, 2026
@illia-v
illia-v enabled auto-merge (squash) October 14, 2026 21:49
@illia-v
illia-v merged commit b066a98 into urllib3:main Oct 14, 2026
72 of 74 checks passed
@00200200
00200200 deleted the codex/ci-memray-plugin-availability branch October 16, 2026 12:56
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