Skip to content

Add no-pr argument to CF LSP #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged

Add no-pr argument to CF LSP #449

merged 1 commit into from
Jun 27, 2025

Conversation

Saga4
Copy link
Contributor

@Saga4 Saga4 commented Jun 27, 2025

PR Type

Enhancement


Description

  • Disable PR creation in LSP server initialization

Changes walkthrough 📝

Relevant files
Configuration changes
server.py
Add no_pr flag to LSP server init                                               

codeflash/lsp/server.py

  • Set args.no_pr = True before optimizer initialization
+1/-0     

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • 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

    Argument Definition

    Ensure that no_pr is declared in the CLI argument parser, otherwise assigning to this attribute will raise an AttributeError during initialization.

    args.no_pr = True  # LSP server should not create PRs
    Processing Order

    Setting args.no_pr before process_pyproject_config may allow the configuration to overwrite this flag. Consider moving this assignment after processing the pyproject config to guarantee it remains true.

    args.no_pr = True  # LSP server should not create PRs
    args = process_pyproject_config(args)

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Preserve no_pr after config processing

    Move this assignment below the call to process_pyproject_config so that any defaults
    or overrides loaded from the pyproject config cannot overwrite the no_pr flag.

    codeflash/lsp/server.py [55]

    +args = process_pyproject_config(args)
     args.no_pr = True  # LSP server should not create PRs
    +self.optimizer = Optimizer(args)
    Suggestion importance[1-10]: 7

    __

    Why: Moving args.no_pr = True below the config processing ensures that any defaults from process_pyproject_config won’t overwrite the intended LSP server behavior, which is a relevant correctness improvement.

    Medium
    Possible issue
    Validate no_pr attribute existence

    Guard the assignment with an hasattr check to ensure no_pr is a valid attribute on
    args and avoid silent attribute errors.

    codeflash/lsp/server.py [55]

    -args.no_pr = True  # LSP server should not create PRs
    +if hasattr(args, "no_pr"):
    +    args.no_pr = True  # LSP server should not create PRs
    +else:
    +    raise AttributeError("no_pr argument missing on args")
    Suggestion importance[1-10]: 3

    __

    Why: Adding an hasattr guard is a minor defensive check that’s likely unnecessary since args should include no_pr from the CLI parser, making this low-impact.

    Low

    @Saga4 Saga4 changed the title Add no-pr argument to CF Add no-pr argument to CF LSP Jun 27, 2025
    @Saga4 Saga4 merged commit 081cc17 into main Jun 27, 2025
    17 checks passed
    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.

    2 participants