Skip to content

Conversation

@alvin-r
Copy link
Contributor

@alvin-r alvin-r commented Apr 1, 2025

PR Type

  • Enhancement
  • Tests

Description

  • Filter out nested class and function definitions.

  • Use qualified name length check for function filtering.

  • Update tests to ensure nested definitions are ignored.


Changes walkthrough 📝

Relevant files
Enhancement
code_context_extractor.py
Filter nested functions and classes in extractor.               

codeflash/context/code_context_extractor.py

  • Added condition to check qualified name depth.
  • Stored qualified name in variable to avoid redundancy.
  • Prevented nested definitions in function extraction.
  • +3/-1     
    Tests
    test_code_context_extractor.py
    Add test case for nested definition filtering.                     

    tests/test_code_context_extractor.py

  • Introduced NestedClass in test file.
  • Updated test to assert only allowed helper methods.
  • Modified main_method integration with nested structure.
  • +10/-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.
  • @alvin-r alvin-r marked this pull request as ready for review April 1, 2025 22:28
    @github-actions
    Copy link

    github-actions bot commented Apr 1, 2025

    PR Reviewer Guide 🔍

    (Review updated until commit 99189a7)

    Here are some key observations to aid the review process:

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

    Edge Case

    Confirm that the inline assignment of the qualified name and its length check does not exclude valid top-level functions in modules with deeper naming hierarchies.

    # Avoid nested functions or classes. Only class.function is allowed and len((qualified_name := get_qualified_name(definition.module_name, definition.full_name)).split(".")) <= 2
    @github-actions
    Copy link

    github-actions bot commented Apr 1, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @github-actions
    Copy link

    github-actions bot commented Apr 1, 2025

    Persistent review updated to latest commit 99189a7

    @github-actions
    Copy link

    github-actions bot commented Apr 1, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @alvin-r alvin-r requested review from KRRT7, Saga4 and misrasaurabh1 April 1, 2025 22:46
    Copy link
    Contributor

    @KRRT7 KRRT7 left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @alvin-r alvin-r merged commit d2bb5ab into main Apr 1, 2025
    17 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    3 participants