Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Python: `.get()`/`.update()` on a typed project-class instance get no edge (dropped as builtins)

Abierto
#2,583 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
40/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, typescript
Área
tooling

Línea de trabajo

Start with isBuiltInOrExternal and PYTHON_BUILT_IN_METHODS in src/resolution/index.ts, where the Python builtin-method filter drops dotted refs before matchMethodCall runs. Reproduce with the two-file example (loader.py and test_packs.py) and check which calls get edges. Done means lines 6, 11 and 12 resolve to SystemPackRegistry::get and ::update while the module-scope d = {}; d.get(...) case stays dropped.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

In Python, a call to a project method named like a builtin collection method (get, update, items, pop, …) is dropped as a builtin unless the receiver variable's name, capitalized, is the name of a project class. This happens even when the receiver's type is known: reg = SystemPackRegistry(); reg.get("y") gets no edge, while the same code with the methods renamed, or with the variable named systemPackRegistry, resolves at 0.9.

Reproduction (verified)

On main at 8fe31569, built from source, Linux (WSL2), Node 22.23.2, WASM extractor (CODEGRAPH_KERNEL=0). Two files:

# loader.py
class SystemPackRegistry:
    def get(self, pack_id):
        return pack_id

    def update(self):
        return None


def load_registry() -> SystemPackRegistry:
    return SystemPackRegistry()
# test_packs.py
from loader import SystemPackRegistry, load_registry


def test_pack():
    registry = load_registry()
    return registry.get("x")      # line 6


def test_ctor():
    reg = SystemPackRegistry()
    reg.update()                  # line 11
    return reg.get("y")           # line 12

codegraph init -i, then the calls / imports / instantiates edges:

load_registry -instantiates-> SystemPackRegistry [loader.py:1] @10 exact-match/0.9
test_packs.py -imports-> SystemPackRegistry [loader.py:1] @1 import/0.9
test_packs.py -imports-> load_registry [loader.py:9] @1 import/0.9
test_pack -calls-> load_registry [loader.py:9] @5 import/0.9
test_ctor -instantiates-> SystemPackRegistry [loader.py:1] @10 import/0.9

There is no edge for lines 6, 11 or 12.

Expected: test_ctor -calls-> SystemPackRegistry::update (line 11) and -> SystemPackRegistry::get (line 12), and test_pack -calls-> SystemPackRegistry::get (line 6), as in the controls below.

Controls, same build:

Change Line 6 Line 11 Line 12
as above none none none
methods renamed get→lookup, update→refresh SystemPackRegistry::lookup instance-method/0.7 SystemPackRegistry::refresh instance-method/0.9 SystemPackRegistry::lookup instance-method/0.9
reg renamed systemPackRegistry none SystemPackRegistry::update instance-method/0.9 SystemPackRegistry::get instance-method/0.9

So the resolver can type both receivers, but the builtin filter runs first and decides from the variable's name alone.

Likely cause (inferred from reading the code)

isBuiltInOrExternal runs before any resolution strategy. For a dotted Python ref whose method is in PYTHON_BUILT_IN_METHODS (get, update, items, pop, read, write, close, …), it keeps the ref only if the capitalized receiver (reg → Reg) is a project class name, or the receiver is an imported project module (#1681). Otherwise it returns true, and the ref is discarded before matchMethodCall can infer the receiver's type from reg = SystemPackRegistry() or -> SystemPackRegistry.

One option is to leave these refs to matchMethodCall when the receiver has a local declaration that the existing receiver-type inference can type, and drop them only when it can't.

Related

  • #1681 / #1749: the same filter dropped module.append() on an imported project module. The fix added the project-module exception, not a typed-receiver one.
  • #1652 / #1776: the filter's module-scope collection check (d = {} then d.get(...)). That case should still be dropped.
  • #1230: the original Python builtin-name false positives this filter guards against.
  • #1947 (open PR): the opposite direction, library-method names on untyped receivers binding to project methods. This issue is about typed receivers losing real edges.

A build of the inth3shadows fork that carries open PRs #1704 and #1926 gives the same output.

Not checked

  • Other names in the set (items, pop, read, close, …); only get and update were run.
  • self.<attr>.get() and parameters annotated with the class (def f(reg: SystemPackRegistry)).
  • The native kernel extractor (only CODEGRAPH_KERNEL=0 was run).
  • Windows and macOS.
Lenguaje dominante
C
Estrellas
73.2k
Forks
4.7k
Merge medio
2 h 13 min
PR fusionados (30 d)
418

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de colbymchenry/codegraph

Todos los issues de colbymchenry/codegraph

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.