Skip to content

Fix rename offsets in Python 3.14 t-strings - #915

Merged
lieryan merged 3 commits into
python-rope:masterfrom
sean0407:fix/python-rope-913-tstring-offsets
Nov 28, 2026
Merged

lieryan merged 3 commits into
python-rope:masterfrom
sean0407:fix/python-rope-913-tstring-offsets

Conversation

@sean0407

Copy link
Copy Markdown
Contributor

Summary

string prefix scan
  recognize t/T prefixes
source offset simplification
  preserve f- and t-string contents
rename regression test
  rename an interpolation without shifting its source span

Fixes #913.

Evidence

  • Before: The issue reports that, with Python 3.14, renaming a in def h():\n a = 1\n f(t"{a}(", ")") produces t"{ab}(": real_code blanks the t-string interpolation and the string-prefix pattern does not recognize t.
  • After: The patch recognizes t/T and preserves t-string text during offset analysis. The added regression asserts that renaming updates the definition and interpolation without moving the surrounding punctuation.
  • Checks: Python AST parsing for the three changed files, git diff --check, and repository patch policy passed (3 text files, 13 changed lines). The regression test and upstream suite were not run locally; the reproduction is issue-supplied and the fix was reviewed statically.

Merge Danger

Door: Two-way

Blast Radius: Narrow

Only Python string-prefix recognition and rename offset analysis change; reverting the patch restores prior behavior.

@sean0407
sean0407 force-pushed the fix/python-rope-913-tstring-offsets branch from a5d06f2 to 20d5e40 Compare October 24, 2026 07:41
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.45%. Comparing base (7dfc36a) to head (4bdd112).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #915   +/-   ##
=======================================
  Coverage   95.45%   95.45%           
=======================================
  Files         134      134           
  Lines       26926    26932    +6     
=======================================
+ Hits        25702    25708    +6     
  Misses       1224     1224           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lieryan
lieryan force-pushed the fix/python-rope-913-tstring-offsets branch from b83865e to fb7d7ed Compare November 28, 2026 15:27
@lieryan
lieryan force-pushed the fix/python-rope-913-tstring-offsets branch from fb7d7ed to 4bdd112 Compare November 28, 2026 15:28
@lieryan
lieryan enabled auto-merge November 28, 2026 15:28
@lieryan
lieryan merged commit ea668be into python-rope:master Nov 28, 2026
24 checks passed
@lieryan

lieryan commented Nov 28, 2026

Copy link
Copy Markdown
Member

Thank you for fixing this issue, @sean0407.

@allcontributors please add @sean0407 for code contribution

@allcontributors

Copy link
Copy Markdown
Contributor

@lieryan

I've put up a pull request to add @sean0407! 🎉

@lieryan lieryan added this to the 1.16.0 milestone Nov 28, 2026
marlon-costa-dc added a commit to marlon-costa-dc/rope that referenced this pull request Dec 1, 2026
Drop the entries inserted into the released 1.15.2+dc.6 section; python-rope#915 is
already credited under dc.11 and python-rope#906 becomes changelog.d/906.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simplify.real_code blanks t-strings, so renames inside them edit the wrong offset

2 participants