Repository navigation
fix Pyrefly inserted typing import in sub-optimal location #1490 - #1580
asukaminato0721 wants to merge 8 commits into
Conversation
e9cb6aa to
c26aa04
Compare
df5401f to
e3180ab
Compare
efd8d5f to
5af20b8
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@asukaminato0721 Are you still planning to make changes to this PR? I see there are some failing checks. |
b1b818e to
0e46400
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
13633fe to
e2b5ced
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Merging this PR will not alter performance
Comparing Footnotes
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Import-edit merging overlapped with autotype dry-run support and newer export-search results. Keep structured edits and follow-up unknown-name imports while ensuring dry runs remain non-mutating and report pending changes correctly.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
Hey @asukaminato0721, I'm making a decision to cut this PR off not because it's necessarily bad, but for two reasons:
Feel free to open a new PR or two covering this, I think we'll be able to turn it around much faster if you do. If you decide to make a new PR, I have some notes to take into account. Note that one of the recommendations is to split this, it's got too much in it for a single PR: P1 — Stale edit offsets corrupt imports (lines 475–493). Edits use the original AST after files have been rewritten. Reproduced from b import marker becoming from b import mar, MissingClassker, with exit code 0. Reparse or batch edits against one current snapshot. P2 — Import controls are bypassed (lines 449–493). --imports=false still adds imports, while --dry-run can report no changes when write mode modifies the file. P2 — Conflicting and duplicate imports (lines 464–493). Every export-search candidate is imported, silently shadowing alternatives. Repeated diagnostics also append the same symbol repeatedly. P2 — User configuration is discarded (lines 453–460). The recheck uses CWD defaults instead of the resolved configuration. Reproduced importing a name explicitly suppressed by the supplied project config. P2 — Deduplication suppresses necessary imports (lines 534–540). The display-string substring check mistakes from a import FooBar for an import of Foo, leaving an inferred annotation unresolved. Recommendation: Keep the import-merging/LSP work, but split out the unknown-name repair pass. It is unrelated to the linked issues and adds a second cold check even on unchanged projects. |
fixes #1490 fixes #3382
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.