Python: calls to a typing.overload'ed function link to the first @overload stub, not the implementation
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Reproduce with the supplied pkg/deco.py and use.py snippets, then inspect the emitted calls edges for command and Prompt.ask; the expected targets are the implementation defs at lines 12 and 30, not the first @overload stubs. Start by locating the Python call-resolution path that maps a call to an indexed definition, and check how it treats multiple defs sharing a name and decorators such as @classmethod. Done means the example’s callers and impact reach the implementation, the run to real_work path is intact, and Python resolution tests cover overload plus classmethod overload cases.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Calls to a Python function or method declared with typing.overload link to the first @overload stub, whose body is just .... The real implementation, the undecorated def that runs, gets no callers, even though its body holds all the callees.
# pkg/deco.py
import typing as t
@t.overload
def command(name: t.Callable) -> int: ... # line 5
@t.overload
def command(name: str | None = None) -> str: ... # line 9
def command(name=None): # line 12, the implementation
return real_work(name)
def real_work(n):
return n
class Prompt:
@t.overload
@classmethod
def ask(cls, p: str) -> str: ... # line 23
@t.overload
@classmethod
def ask(cls, p: str, d: int) -> int: ...
@classmethod
def ask(cls, p, d=None): # line 30, the implementation
return real_work(p)
# pkg/__init__.py
from .deco import command, Prompt
# use.py
import pkg
from pkg import command, Prompt
@pkg.command()
def cli():
pass
def run():
command("x")
Prompt.ask("y")
| call | edge on main |
expected |
|---|---|---|
@pkg.command() |
command at line 5 (stub) |
line 12 |
command("x") |
command at line 5 (stub) |
line 12 |
Prompt.ask("y") |
ask at line 23 (stub) |
line 30 |
All six defs are indexed as separate nodes. The stubs have no callees, and the implementations have the callees but no callers. So callers/impact on the implementation come back empty, the call path from run to real_work breaks at the stub, and the implementation looks unreferenced.
Reproduced on main at 72f398af, with CODEGRAPH_KERNEL=0 and with the native kernel. Linux/WSL2, Node 22.23.2.
Where it shows up. Libraries that type their public API with overloads are hit hardest. Checking every Python calls edge against jedi's goto-definition:
- In click (2247b35),
commandinsrc/click/decorators.pyhas stubs at lines 138, 144, 153 and 163 and the implementation at 168. 345 call edges land on the line-138 stub and 2 on the implementation. Most of click's 473 disagreeingimportedges are this (group,edit,progressbar,prompt,convert_type, …). - In rich (9d8f9a3),
Confirm.ask/Prompt.askandrich.progress.openland on their first stub the same way.
Expected. For a Python name with @overload stubs plus an implementation, link calls to the implementation (the def without @overload). If a stub is kept for its signature, the implementation should still be the callee. #2213 ("any call reaches the overload its arguments fit") covers languages whose overloads are separate implementations. A Python call always runs the one undecorated def.
Related: #2213.
- Ngôn ngữ chính
- C
- Star
- 73.2k
- Fork
- 4.7k
- Merge trung bình
- 3 giờ 46 phút
- Pull request đã merge (30 ngày)
- 510
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của colbymchenry/codegraph
-
Separate Installation Commands into Individual Code BlocksCó thể đã có người làm @andrySD đã nhận 1 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
colbymchenry/codegraph#3241 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
colbymchenry/codegraph#3228 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
colbymchenry/codegraph#3223 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A `../` entry in package.json `workspaces` makes a folder outside the project count as a workspace package, and a call gets linked to the wrong functionCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
colbymchenry/codegraph#3093 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows: npm-shim spawnSync missing windowsHide flashes a console window on every MCP server launchĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
colbymchenry/codegraph#3054 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của colbymchenry/codegraph
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
ly05010419/MacNativeGames#1796 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Wi-Fi associates with a distant AP on multi-AP networks (fast scan, no signal sorting)Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
jniebuhr/gaggimate#1009 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Bug :bug:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
sonic-net/sonic-buildimage#30563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
llvm/offload-test-suite#1698 ·
Maintainer thường phản hồi trong vòng 1 ngày