Skip to content

Bug in Python parsing, class/static methods not added as CALLS edges #228

@mandricmihai

Description

@mandricmihai

Try to index the attached example, is not able to find the methods and it results in false positives as dead code.

build_from_text build_from_mapping are not indexed, in degree 0, out degree 0

"""Module demonstrating direct class usage — baseline case."""
from core.schemas import ActionRecordX


def run_plain_flow():
    """Invokes constructor helper without aliasing."""
    return ActionRecordX.build_from_text("hello")


def adapt_plain_flow():
    """Invokes alternate constructor without aliasing."""
    return ActionRecordX.build_from_mapping({"label": "world"})


"""Module demonstrating aliased import — alias resolution case."""
from core.schemas import ActionRecordX as ActionAlias


def run_alias_flow():
    """Invokes constructor helper via alias."""
    return ActionAlias.build_from_text("hello")


def adapt_alias_flow():
    """Invokes alternate constructor via alias."""
    return ActionAlias.build_from_mapping({"label": "world"})


from pydantic import BaseModel


class ActionRecordX(BaseModel):
    label: str

    @classmethod
    def build_from_text(cls, raw: str) -> "ActionRecordX":
        return cls(label=raw)

    @classmethod
    def build_from_mapping(cls, payload: dict) -> "ActionRecordX":
        return cls(label=payload["label"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions