Skip to content

Python: a builtin like TimeoutError links an unrelated project class of that name in a file that isn't imported #3232

Closed

Description

@inth3shadows

What happens

raise TimeoutError(...) in a file that neither defines nor imports TimeoutError uses Python's builtin. codegraph links it to a project class TimeoutError in an unrelated file.

# other/far.py
class TimeoutError(Exception):
    pass

# t.py (no imports)
def run():
    raise TimeoutError("late")       # the builtin
  • Expected: no edge. A bare name a file neither binds nor imports (and doesn't star-import) can only be a builtin.
  • Actual: run instantiates other/far.py TimeoutError (resolvedBy: exact-match).

Projects that define their own TimeoutError, ConnectionError, PermissionError and similar classes are common, so every file that raises the builtin gains an edge to one of them.

Real case in openevolve at 73448d7: examples/algotune/affine_transform_2d/evaluator.py:87 (raise TimeoutError(...), imports nothing named TimeoutError) instantiates class TimeoutError in examples/circle_packing/evaluator.py:23.

Found by diffing codegraph's call edges against scip-python (pyright's references).

Environment: main at f72c9d2 (2026-11-01), built from source, Node 22.22.2, Linux x64, WASM engine (CODEGRAPH_KERNEL=0), fresh codegraph init. A 60b0d7a build (2026-10-29) gives the same edges.

Related: #3230 and #3231 end the same way: a bare Python name falls back to a same-named symbol in a file that isn't imported. #2198 added the local-binding check; a builtin has no binding for it to find.

Edited 2026-11-04: re-checked on main at f72c9d2 (with CODEGRAPH_KERNEL=0 and with the native kernel, Node 22.22.2): still reproduces. Corrected two slips: ValidationError isn't a Python builtin, so I replaced it in the list; and the real-case file does import one project module (openevolve.evaluation_result), just nothing named TimeoutError. Added: ValueError and KeyError leak the same way, and so does return TimeoutError(...); except TimeoutError makes no edge. Cause (inferred): the resolver's built-in list, PYTHON_BUILT_INS, has no exception names.

Activity

  1. added 6 commits that reference this issue on Nov 17, 2026
    54c815a
    1d21e7a
    5012e78
    3c144da
    eb12715
    84bd353
  2. colbymchenry commented on Nov 18, 2026

    @colbymchenry
    Owner

    Thanks for the report, @inth3shadows. A builtin written bare, like raise TimeoutError(…), class Bad(ValueError) or sorted(rows), no longer links to a project class or function of that name in a file the code doesn't import. A name the file defines or imports itself still resolves as before. The fix is #3357. It is merged to main today (2026-11-18) and ships in the next release.

  3. added a commit that references this issue on Nov 18, 2026
    962e879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions