Python constructor calls do not reach the initializer they run
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with the Python call-graph construction and change-impact traversal, then inspect PR #4208, which describes the proposed constructor-entry edge and its scope. Reproduce the supplied fixture with graphify update and graphify affected; compare the graph before and after, including incremental output against a clean rebuild. Done means constructor calls reach the inferred initializer and callers while preserving all existing nodes and edges and respecting the documented static-analysis limitations.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Python constructor calls stop at the class node, hiding the initializer's dependencies from change-impact traversal.
Reproduction on current v8
Verified on v0.9.80, commit 6478eb7, with Python 3.13 on Linux. Build these files with graphify update <fixture> --no-cluster:
# pkg/storage.py
def open_db(path):
return path
class Store:
def __init__(self, path):
self.db = open_db(path)
# pkg/cache.py
from pkg.storage import Store
class CachedStore(Store):
pass
# pkg/service.py
from pkg.cache import CachedStore
def build(path):
return CachedStore(path)
# tests/test_service.py
from pkg.service import build
def test_build():
build("test.db")
graphify affected "open_db()" --depth 4 --graph <fixture>/graphify-out/graph.json finds Store.__init__ but misses build() and test_build(). The call graph has build -> CachedStore and Store.__init__ -> open_db, with no call edge joining them.
Constructor fix
PR #4208 adds an inferred constructor-entry edge when a supported source binding and class chain identify the initializer. It preserves the class edge and every other existing node and edge. The fixture then reaches the initializer, build(), its importing test file, and test_build(). Incremental output after editing the caller matches a clean rebuild.
Fresh comparisons against 6478eb7 add 703 constructor edges across seven pinned repositories: Flask 3, requests 3, httpx 56, rich 506, langchain-core 100, yt-dlp 17 and FastAPI 18. All 703 agree with an independent Python ast derivation. All 586 that SCIP can judge agree on the called class, inheritance chain and initializer. Every pre-existing node and edge remains identical.
This is a restricted static subset. Decorators, metaclasses, custom allocation, multiple inheritance, ambiguous bindings, external bases and known mutation patterns add no edge. Cross-module dynamic mutation remains a documented limitation.
Why it matters for test impact
A separate runtime-trace study measured Flask and yt-dlp tests against pinned source revisions. Historical v8 graphs reached only 4 of 3,482 sampled Flask test/function pairs and 20 of 606 yt-dlp pairs. A broader prototype combining receiver typing, constructor entry and pytest fixture dependencies reached 1,699 and 358 respectively. Those are historical prototype results, not the results of this constructor PR or current v0.9.80.
Constructor entry is one missing link in that chain. Since the study, upstream has added self.attr.method() support in #4176 and annotated/constructor-bound local receiver support in #4198. Those changes are already present in the base used to verify this PR. Remaining opportunities include inherited methods, factory return types and pytest fixture dependency edges through the nearest conftest.py chain.
Related: #2041, #2860, #2417, #2586 and #1499.
- Lingua principale
- Python
- Stelle
- 124k
- Fork
- 11.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Graphify-Labs/graphify
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
Graphify-Labs/graphify#3763 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Graphify-Labs/graphify#3611 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Nix supportAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Graphify-Labs/graphify#3193 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
Graphify-Labs/graphify#2871 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Graphify-Labs/graphify#2865 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Graphify-Labs/graphify
Issue simili
-
customer-reported question
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Azure/azure-sdk-for-python#49548 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
btclib-org/btclib-wallet#409 ·
I maintainer di solito rispondono entro 1 giorno
-
Phase 2 PSA Capability & Career Profile
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fastmachinelearning/hls4ml#1582 ·
I maintainer di solito rispondono entro 3 giorni
-
Sort modelsApertaenhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno