Merged
Conversation
Contributor
Author
|
@greptileai plz re-review |
Contributor
|
@greptile-ai re-review |
Contributor
Author
|
@greptileai plz re-review |
packages/cli/src/fs/determineFramework/matchSetupPyDependency.ts
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@greptileai plz re-review |
Contributor
|
@greptile-ai re-review |
Contributor
|
@claude review pls |
archie-mckenzie
approved these changes
Mar 9, 2026
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Comment on lines
+67
to
+71
| source = fs.readFileSync(filePath, 'utf8'); | ||
| } catch { | ||
| crossFileCache.set(cacheKey, null); | ||
| return null; | ||
| } |
Contributor
There was a problem hiding this comment.
resolveFunctionInFile is async but uses synchronous fs.readFileSync() to read files. This blocks the Node.js event loop during cross-file helper resolution, which can cause noticeable stalls when projects have deep re-export chains.
Use fs.promises.readFile to keep the function non-blocking:
Suggested change
| source = fs.readFileSync(filePath, 'utf8'); | |
| } catch { | |
| crossFileCache.set(cacheKey, null); | |
| return null; | |
| } | |
| let source: string; | |
| try { | |
| source = await fs.promises.readFile(filePath, 'utf8'); | |
| } catch { | |
| crossFileCache.set(cacheKey, null); | |
| return null; | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/python-extractor/src/resolveFunctionVariants.ts
Line: 67-71
Comment:
`resolveFunctionInFile` is `async` but uses synchronous `fs.readFileSync()` to read files. This blocks the Node.js event loop during cross-file helper resolution, which can cause noticeable stalls when projects have deep re-export chains.
Use `fs.promises.readFile` to keep the function non-blocking:
```suggestion
let source: string;
try {
source = await fs.promises.readFile(filePath, 'utf8');
} catch {
crossFileCache.set(cacheKey, null);
return null;
}
```
How can I resolve this? If you propose a fix, please make it concise.
Merged
ErnestM1234
pushed a commit
that referenced
this pull request
Mar 9, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## gt@2.8.0 ### Minor Changes - [#1088](#1088) [`2cad388`](2cad388) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - feat: add python support for registration ### Patch Changes - Updated dependencies \[[`2cad388`](2cad388)]: - @generaltranslation/python-extractor@0.1.0 ## @generaltranslation/python-extractor@0.1.0 ### Minor Changes - [#1088](#1088) [`2cad388`](2cad388) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - feat: add python support for registration ## gtx-cli@2.8.0 ### Patch Changes - Updated dependencies \[[`2cad388`](2cad388)]: - gt@2.8.0 ## locadex@1.0.112 ### Patch Changes - Updated dependencies \[[`2cad388`](2cad388)]: - gt@2.8.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add python registration support:
t('hello, {name}', name='john', _max_chars=10), also supportsdeclare_static()/declare_var()syntaxGreptile Summary
This PR adds Python translation support to the CLI, introducing a new
@generaltranslation/python-extractorpackage and wiring it into the existing push pipeline. It handlest('hello, {name}', name='john', _max_chars=10)call extraction along with thedeclare_static()/declare_var()DSL for static and runtime variable interpolation. The refactored shared post-processing utilities (calculateHashes,dedupeUpdates,linkStaticUpdates) are a clean improvement that eliminates duplication between the React and Python pipelines.Key changes:
python-extractorpackage: tree-sitter-based AST extraction oft()/msg()calls from Python source files, including cross-file helper resolution and cartesian expansion ofdeclare_staticvariants.pyproject.toml,requirements.txt, andsetup.pyusing proper parsers.createPythonInlineUpdatesCLI integration, routed viaisPythonLibrarytype guard intranslation/parse.ts.calculateHashes/dedupeUpdates/linkStaticUpdatesextracted to a sharedextraction/postProcess.ts.Issues found:
resolveFunctionInFileinresolveFunctionVariants.tsuses synchronousfs.readFileSyncinside anasyncfunction, blocking the event loop during cross-file resolution. It should usefs.promises.readFile.Confidence Score: 4/5
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["CLI push command\n(translation/parse.ts)"] --> B{"isPythonLibrary?"} B -- yes --> C["createPythonInlineUpdates\n(python/parse/)"] B -- no --> D["createInlineUpdates\n(react/parse/)"] C --> E["matchFiles\n(.py glob)"] E --> F["extractFromPythonSource\n(python-extractor)"] F --> G["extractImports\n(GT import aliases)"] G --> H["extractCalls\n(t / msg calls)"] H --> I{"hasStaticHelpers?"} I -- yes --> J["parseStringExpression\n(StringNode tree)"] J --> K["resolveDeclareStaticArg\n/ resolveDeclareVarArg"] K --> L["resolveFunctionCall\n(cross-file resolution)"] L --> M["resolveFunctionInFile\n(crossFileCache)"] I -- no --> N["extractStringContent\n(plain string)"] J --> O["nodeToStrings\n(cartesian expand)"] N --> P["ExtractionResult[]"] O --> P P --> Q["mapExtractionResultsToUpdates"] Q --> R["calculateHashes"] R --> S["dedupeUpdates"] S --> T["linkStaticUpdates\n(sharedStaticId)"] T --> U["Updates[]"]Comments Outside Diff (1)
python-extractor-detailed-plan.md, line 1 (link)This detailed plan document is committed to the repo root and is now stale. Its "Phase 2 (Future)" section lists
declare_static,declare_var, andmsg()support as not yet implemented, but this PR implements all three features.Committed design documents tend to drift out of sync and can mislead future contributors. Consider removing this file or relocating it to a
docs/or.github/directory if you want to preserve it as a living design reference.Prompt To Fix With AI
Last reviewed commit: 57ce390