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     

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)

Copy link

PR Code Suggestions ✨

No code suggestions found for the PR.

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.

1 participant