patchedast: visitors that omit sub-nodes leave unconsumed text that later token searches mis-match
I maintainer di solito rispondono entro 7 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 46/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
_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.
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 197
- Merge medio
- 2g 13h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-rope/rope
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
python-rope/rope#927 ·
I maintainer di solito rispondono entro 7 giorni
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionForse già presa @aliassar l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
python-rope/rope#926 ·
I maintainer di solito rispondono entro 7 giorni
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetForse già presa @sean0407 l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
python-rope/rope#913 ·
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
python-rope/rope#925 ·
I maintainer di solito rispondono entro 7 giorni
-
Extract method/variable and introduce parameter don't check whether the new name is already in useAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
python-rope/rope#924 ·
I maintainer di solito rispondono entro 7 giorni
Tutte le issue di python-rope/rope
Issue simili
-
Paraxial.trace returns NaN for an object at infinity when the entrance pupil is at the first surfaceAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement ios launcher
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/datafusion#27059 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
loteran/Arctis-Sound-Manager#368 ·
I maintainer di solito rispondono entro 1 giorno
-
feed submission
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MobilityData/mobility-database-catalogs#1787 ·
I maintainer di solito rispondono entro 2 giorni