pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

fix Pyrefly inserted typing import in sub-optimal location #1490

Open asukaminato0721 opened this issue 1 month ago • 1 comments

fix #1490

Adjusted so insert_import_edit* returns an ImportEdit with both the actual edit and a stable display string, and added logic to append new symbols to an existing matching from ... import ... statement instead of duplicating the import line. The helper now shares this richer info with callers so UI text stays human-readable.

Updated LSP code to consume the new struct, ensuring code-action titles and auto-import completion details still show from module import name while the actual edit mutates the existing line in place.

Taught the infer command to handle the new edit type and to skip empty/duplicate insertions when mutating files.

Revised the LSP code-action test to assert the merged-import behavior.

asukaminato0721 avatar Nov 14 '25 06:11 asukaminato0721

@jvansch1 has imported this pull request. If you are a Meta employee, you can view this in D87254329.

meta-codesync[bot] avatar Nov 20 '25 20:11 meta-codesync[bot]

This pull request has been automatically marked as stale because it has not had recent activity for more than 2 weeks.

If you are still working on this this pull request, please add a comment or push new commits to keep it active. Otherwise, please unassign yourself and allow someone else to take over.

Thank you for your contributions!

github-actions[bot] avatar Dec 18 '25 00:12 github-actions[bot]