patchedast: visitors that omit sub-nodes leave unconsumed text that later token searches mis-match
Maintainer antworten meist innerhalb von 7 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 46/100
Rechercherichtung
Start in rope/base/ast.py and trace _PatchingASTWalker plus the visitors named in the issue, including _arguments, _arg, _handle_function_def_node, _JoinedStr, _ClassDef and _TryFinally. Reproduce the listed cases with patchedast.get_patched_ast(src, sorted_children=True), then add a regression check that relevant AST nodes and string literals receive regions covering their AST spans. Done means the cases no longer raise or leave source text without a region.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
_PatchingASTWalker finds each token with a forward source.index, so any source text a visitor does not
list is skipped as whitespace; a (, ), = or quote inside it is then matched as a later token. The
walk raises MismatchedTokenError / AttributeError: 'NoneType' object has no attribute 'group', or it
silently produces wrong regions, which Scope.get_region uses for scope lookup. On rope 1.15.0, each
repro below makes patchedast.get_patched_ast(src, sorted_children=True) either raise or finish with part
of the source left without a region:
- posonly / kw-only args and
kw_defaults(_arguments):def f(*, m: str = "(host)"): pass - parameter annotations (
_arg):def f(p: A[F(d="t")] = None): pass - return annotations (
_handle_function_def_node):def f() -> A[F(d="(")]: pass *args/**kwargsannotations:def f(*a: F("("), **k: F(")")): pass- f-string implicitly concatenated with a later literal (
_JoinedStrstops at the f-string's quote):
c = g(f"{d}" "(") - class keywords (
_ClassDef):class A(B, metaclass=M, x=")"): pass elseoftry/except/else/finally(_TryFinally): anelse:body holdingx = "("rb/Rbprefixes (string pattern[uUbB]?[rR]?):x = rb"("; the region starts afterr- 3.14 t-strings:
TemplateStr/Interpolationare unknown nodes:f(t"{a}(", ")") - 3.12+ nested f-strings that reuse the outer quote:
x = f"{f"{a}("}" ")"(the string regex stops at
the inner quote)
Suggested regression test: after walking any module, every AST node except context/operator nodes,
withitem and f-string internals has a region, and every string literal's region covers its
ast span. With that check, CPython's stdlib and a 1,200-file project pass once the visitors above are
fixed. We carry these patches in living-architecture's rope_patches.py and will drop each when it
lands upstream.
- Vorherrschende Sprache
- Python
- Sterne
- 2.2k
- Forks
- 197
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-rope/rope
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
python-rope/rope#927 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionEvtl. vergeben @aliassar hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
python-rope/rope#926 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetEvtl. vergeben @sean0407 hat das vor 11 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
python-rope/rope#913 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
python-rope/rope#925 ·
Maintainer antworten meist innerhalb von 7 Tagen
-
Extract method/variable and introduce parameter don't check whether the new name is already in useOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
python-rope/rope#924 ·
Maintainer antworten meist innerhalb von 7 Tagen
Alle Issues in python-rope/rope
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/onnxscript#3155 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug docs severity:low
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
docs good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100