Repository navigation
Find textual occurrence offsets through the tokenizer - #906
Open
marlon-costa-dc wants to merge 1 commit into
Open
marlon-costa-dc wants to merge 1 commit into
marlon-costa-dc wants to merge 1 commit into
Conversation
The regex finder captured f-strings and parsed each capture with ast.parse to locate names inside replacement fields; a PEP 701 f-string whose replacement field reuses the outer quote or carries a format spec produces a capture that is not valid standalone source, so rename missed occurrences there (and issue python-rope#815 reports ast.parse SyntaxErrors). Tokenizing the source instead yields every NAME token, including those inside 3.12+ replacement fields, and never matches names inside comments or string literals.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #906 +/- ##
==========================================
- Coverage 95.34% 95.31% -0.04%
==========================================
Files 134 134
Lines 26762 26754 -8
==========================================
- Hits 25516 25500 -16
- Misses 1246 1254 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
The regex-based
_TextualFindercaptured f-strings and parsed each capture withast.parseto locate names inside replacement fields. A PEP 701 f-string whose replacement field reuses the outer quote or carries a format spec produces a capture that is not valid standalone source, so rename missed occurrences there andast.parseraisedSyntaxError(issue #815, also the subject of #816).Tokenizing the source instead yields every
NAMEtoken, including those inside 3.12+ replacement fields, and never matches names inside comments or string literals — so_search_in_f_stringand its regex scaffolding disappear entirely.Tests cover renaming inside f-strings that reuse the outer quote and inside format specs (
f"{a_var:>{a_var}}"); the existing rename suite stays green (99 passed locally on 3.13).