patchedast: visitors that omit sub-nodes leave unconsumed text that later token searches mis-match
Mantenedores costumam responder em até 7 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 46/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
_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.
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 197
- Merge médio
- 2d 13h
- PRs com merge (30d)
- 5
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-rope/rope
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
python-rope/rope#927 ·
Mantenedores costumam responder em até 7 dias
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionTalvez já em andamento @aliassar assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
python-rope/rope#926 ·
Mantenedores costumam responder em até 7 dias
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetTalvez já em andamento @sean0407 assumiu há 10 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
python-rope/rope#913 ·
Mantenedores costumam responder em até 7 dias
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
python-rope/rope#925 ·
Mantenedores costumam responder em até 7 dias
-
Extract method/variable and introduce parameter don't check whether the new name is already in useAberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 62/100
python-rope/rope#924 ·
Mantenedores costumam responder em até 7 dias
Todas as issues de python-rope/rope
Issues semelhantes
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
QuantConnect/Documentation#2838 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · 1 comentário ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultAbertabug pkg:harness
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
pydantic/pydantic-ai#12405 ·
Mantenedores costumam responder em até 1 dia
-
good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
good first issue help wanted
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100