-
Notifications
You must be signed in to change notification settings - Fork 22
[LSP] Init flow #817
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
[LSP] Init flow #817
Conversation
|
Codeflash Bot seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
PR Reviewer Guide 🔍(Review updated until commit 71f8076)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 71f8076
Previous suggestionsSuggestions up to commit 7aee1c1
|
|
Persistent review updated to latest commit 71f8076 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should add unit tests, cmd_init is an important workflow
The optimized version improves performance by **replacing the `while isinstance()` condition with a tighter `while True` loop** that explicitly checks types inside the loop body. This eliminates redundant `isinstance()` calls on each iteration. **Key optimizations:** 1. **Eliminated redundant type checking**: The original code calls `isinstance(current, ast.Attribute)` twice per iteration - once in the while condition and again when accessing `current.value`. The optimized version uses a single `isinstance()` check per iteration. 2. **More efficient loop structure**: Changed from `while isinstance(current, ast.Attribute):` to `while True:` with explicit type checks and early exits using `continue` and `break`. This reduces function call overhead on each loop iteration. 3. **Direct variable assignment**: Uses `val = current.value` once and reuses it, avoiding repeated property access. **Performance impact by test case type:** - **Simple names** (`foo()`): ~133% faster due to reduced overhead in the fast path - **Attribute chains** (`obj.bar()`, `pkg.mod.func()`): ~114-225% faster, with deeper chains seeing more benefit - **Long chains** (100+ attributes): ~70% faster, where the loop optimization compounds significantly - **Edge cases** (non-callable nodes): ~92-191% faster due to faster bailout paths The optimization is particularly effective for **attribute chain resolution**, which is common in method calls and module imports - the primary use case for this AST analysis code.
…CallFinder._get_call_name-mgzrorsj ⚡️ Speed up method `FunctionCallFinder._get_call_name` by 113%
⚡️ Codeflash found optimizations for this PR📄 6,107,867% (61,078.67x) speedup for
|
User description
Description
Extract common init suggestion helpers
Add cached valid subdirs discovery
Split test framework detection paths
Improve interactive choices with icons
Diagram Walkthrough
File Walkthrough
cmd_init.py
Refactor init helpers and framework detectioncodeflash/cli_cmds/cmd_init.py
PR Type
Enhancement, Bug fix
Description
Add LSP-aware init and config flow
Split test framework detection paths
Provide cached directory suggestions
Improve pyproject read/write robustness
Diagram Walkthrough
File Walkthrough
cmd_init.py
LSP-friendly init helpers and config writercodeflash/cli_cmds/cmd_init.py
beta.py
LSP endpoints for config suggestions and writingcodeflash/lsp/beta.py
config_parser.py
LSP-safe config parsing and defaultscodeflash/code_utils/config_parser.py