Skip to content

feat: warn when running on an unsupported Python version - #133

Open
not-matthias wants to merge 1 commit into
masterfrom
cod-3400-warn-when-running-pytest-codspeed-with-unsupported-python
Open

feat: warn when running on an unsupported Python version#133
not-matthias wants to merge 1 commit into
masterfrom
cod-3400-warn-when-running-pytest-codspeed-with-unsupported-python

Conversation

@not-matthias

Copy link
Copy Markdown
Member

Print a warning in the pytest header when the running interpreter is outside the
Python version range pytest-codspeed claims to support:

WARNING: Python 3.16 is not officially supported by pytest-codspeed (supported:
3.9 to 3.15). Support is experimental and untested, measurements may be unreliable.

Customers upgrading Python currently get silent, unvalidated measurements: nothing
tells them the interpreter they benchmark on was never tested. Surfacing it in the
header means it lands in the CI log right under the existing codspeed: <version>
line, next to the other notices.

The bounds live in pytest_codspeed.utils and mirror requires-python plus the
Programming Language :: Python classifiers in pyproject.toml and the CI matrix.
The issue did not specify a list, and the sources disagreed: the classifiers and CI
say 3.15, while the README badge says 3.14 and the docs badge 3.13. The badges are
stale (docs still claimed 3.13 well after 3.14 classifiers shipped), so the bounds
follow the classifiers. Warning on 3.15 would contradict the package's own metadata
and redden the 3.15 CI legs.

test_get_python_version_warning_supported asserts no warning fires on the
interpreter running the suite, so adding a Python version to the CI matrix without
bumping the constant fails loudly instead of silently warning users.

Not included: the "warning on the Run page" half of the issue is platform-side. The
plugin already ships full interpreter metadata via get_environment_metadata and
collect_and_write_python_environment, so no extra plumbing is needed here.

Refs COD-3400

@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown

Merging this PR will regress 7 benchmarks

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 12 improved benchmarks
❌ 7 regressed benchmarks
✅ 203 untouched benchmarks
⏩ 55 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_recursive_fibo_20 5.3 ms 5.9 ms -9.39%
WallTime test_noop_lambda_decorated 1.3 µs 1.3 µs -4.87%
WallTime test_mmap_operation[409600] 128.5 µs 135.1 µs -4.85%
Memory test_multiprocessing_map[100] 3.2 MB 3.4 MB -3.83%
WallTime test_generate_sum_of_subsets_soln[nums0-9] 26.1 µs 27.1 µs -3.54%
WallTime test_noop_pass_decorated 658.4 ns 680.7 ns -3.27%
WallTime test_tcp_connection[1.1.1.1-53] 948.1 µs 973.5 µs -2.6%
WallTime test_multiprocessing_map[100000] 419.4 ms 320.6 ms +30.83%
WallTime test_multiprocessing_map[1000] 59.2 ms 51 ms +16.01%
Memory test_multiprocessing_map[10] 4.1 MB 3.6 MB +13.73%
Memory test_multiprocessing_map[10000] 3.4 MB 3.1 MB +9.28%
Memory test_multiprocessing_map[100000] 6.2 MB 5.7 MB +8.93%
WallTime test_sum_of_squares[sum_of_squares_sum_labmda_power] 350.4 µs 325.7 µs +7.59%
Memory test_multiprocessing_map[1000] 3.7 MB 3.5 MB +5.86%
WallTime test_get_valid_pos[pos0-4] 2.9 µs 2.7 µs +4.98%
WallTime test_sum_of_squares[sum_of_squares_sum_comprehension_power] 238.5 µs 230.7 µs +3.4%
WallTime test_solve_maze[maze0] 24.8 µs 24.1 µs +3.09%
WallTime test_make_highpass 5.5 µs 5.4 µs +2.91%
WallTime test_open_close_fd[100] 901.6 µs 876.9 µs +2.81%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cod-3400-warn-when-running-pytest-codspeed-with-unsupported-python (4e49265) with master (c7e9981)

Open in CodSpeed

Footnotes

  1. 55 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@not-matthias
not-matthias force-pushed the cod-3400-warn-when-running-pytest-codspeed-with-unsupported-python branch from e09ec2d to 2345b56 Compare August 27, 2026 16:16
@not-matthias

Copy link
Copy Markdown
Member Author

@greptileai review

@not-matthias
not-matthias marked this pull request as ready for review August 27, 2026 16:26
Print a warning in the pytest header when the interpreter is outside the version
range pytest-codspeed claims to support, so customers upgrading Python are told
their measurements run on an untested interpreter instead of getting silent,
unvalidated results.

On GitHub Actions the warning is emitted as a `::warning` workflow command so it
becomes an annotation shown outside the job log; on GitLab CI, which has no
annotation mechanism, the line is coloured instead. Mirrors the `warnCi` helper
of the codspeed-node counterpart, including the percent-encoding of
workflow-command syntax.

The bounds mirror `requires-python` and the `Programming Language :: Python`
classifiers in pyproject.toml, and the CI matrix.

Refs COD-3400
@not-matthias
not-matthias force-pushed the cod-3400-warn-when-running-pytest-codspeed-with-unsupported-python branch from 2345b56 to 4e49265 Compare August 27, 2026 16:30
@not-matthias
not-matthias marked this pull request as draft August 27, 2026 16:32
@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a pytest-header notice when the active interpreter falls outside the supported Python 3.9–3.15 range.

  • Defines supported-version bounds and formats local or GitHub Actions warnings.
  • Adds unit and pytest integration coverage for supported, unsupported, and annotation output.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
src/pytest_codspeed/plugin.py Adds supported-version bounds, warning formatting, and inclusion of the warning in pytest's report header.
tests/test_pytest_plugin.py Adds tests for supported and unsupported versions, GitHub Actions annotations, and header integration.

Reviews (2): Last reviewed commit: "feat: warn when running on an unsupporte..." | Re-trigger Greptile

Comment thread src/pytest_codspeed/utils.py Outdated
if os.environ.get("GITHUB_ACTIONS") == "true":
title = _escape_workflow_command_property(title)
return f"::warning title={title}::{_escape_workflow_command_data(message)}"
return f"\033[93m{message}\033[0m"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 ANSI ignores color settings

On an unsupported interpreter outside GitHub Actions, format_ci_warning embeds ANSI sequences even when pytest uses --color=no or writes to redirected output, leaving terminal-control bytes in non-color logs.

Knowledge Base Used: Validation and benchmark fixtures

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/pytest_codspeed/utils.py
Line: 75

Comment:
**ANSI ignores color settings**

On an unsupported interpreter outside GitHub Actions, `format_ci_warning` embeds ANSI sequences even when pytest uses `--color=no` or writes to redirected output, leaving terminal-control bytes in non-color logs.

**Knowledge Base Used:** [Validation and benchmark fixtures](https://app.greptile.com/codspeed/-/custom-context/knowledge-base/codspeedhq/pytest-codspeed/-/docs/validation-and-benchmark-fixtures.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@not-matthias
not-matthias marked this pull request as ready for review August 27, 2026 17:08
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.

1 participant