Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#2,583 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
40/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, typescript
Domain
tooling

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
C
Stars
73.2k
Forks
4.7k
Avg merge
2h 13m
Merged PRs (30d)
418

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from colbymchenry/codegraph

All issues in colbymchenry/codegraph

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.