Skip to content

Conversation

@KRRT7
Copy link
Contributor

@KRRT7 KRRT7 commented Aug 24, 2025

PR Type

Bug fix


Description

  • Prevent duplicate benchmark option registration

  • Add conditional guard based on pytest-benchmark installation


Diagram Walkthrough

flowchart LR
  A["pytest_addoption invoked"] --> B{"PYTEST_BENCHMARK_INSTALLED?"}
  B -- "False" --> C["Register benchmark_options"]
  B -- "True" --> D["Skip registration"]
Loading

File Walkthrough

Relevant files
Bug fix
plugin.py
Conditional benchmark options registration                             

codeflash-benchmark/codeflash_benchmark/plugin.py

  • Wrapped benchmark options registration in a conditional check
  • Introduced PYTEST_BENCHMARK_INSTALLED guard
  • Removed unconditional loop adding benchmark_options
+5/-4     

@github-actions
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Undefined guard variable

Ensure PYTEST_BENCHMARK_INSTALLED is defined and properly imported or initialized to avoid NameError at runtime.

# Only add benchmark options if pytest-benchmark is not installed for backward compatibility with existing pytest-benchmark setup
if not PYTEST_BENCHMARK_INSTALLED:
    for option, action, default, help_text in benchmark_options:
        help_suffix = " (ignored when --codeflash-trace is used)"
        parser.addoption(option, action=action, default=default, help=help_text + help_suffix)

@github-actions
Copy link

PR Code Suggestions ✨

No code suggestions found for the PR.

@KRRT7 KRRT7 requested review from a team and misrasaurabh1 October 22, 2025 07:02
@aseembits93
Copy link
Contributor

@KRRT7 status on this?

@KRRT7
Copy link
Contributor Author

KRRT7 commented Oct 28, 2025

@aseembits93 it's ready to be merged, just needs to be approved

@aseembits93 aseembits93 enabled auto-merge October 28, 2025 21:36
@aseembits93 aseembits93 merged commit 0018e59 into main Oct 28, 2025
21 of 23 checks passed
@KRRT7 KRRT7 deleted the pytest-benchmark-err-fix branch October 28, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants