Skip to content

function as parameter omitted in 2.2.0 #116

@doctorgu

Description

@doctorgu

get_db_read function is actually calling but disappeared in 2.2.0

  • sample.py
from fastapi import Depends
from database.depends import get_db_read

def get_id(db = Depends(get_db_read)):
    return db.query(1).all()
  • test code for sample.py
def bug_depends_get_db_read():
    """
    bug depends get_db_read
    """
    
    file_name = os.path.join(os.path.dirname(__file__), "sample.py")
    visitor = CallGraphVisitor([file_name])
    visitor.process_one(file_name)

    # traverse all children deep
    edges = visitor.uses_edges
    for start_node in edges:
        descendants = set()
        stack = [start_node]
        
        while stack:
            curr = stack.pop()
            for child in edges.get(curr, set()):
                if child not in descendants:
                    descendants.add(child)
                    stack.append(child)
                    
        for child in descendants:
            print(f"{start_node.namespace}.{start_node.name} -> {child.namespace}.{child.name}")
  • 2.1.0:
.sample -> database.depends.get_db_read
.sample -> fastapi.Depends
sample.get_id -> database.depends.get_db_read -> disappeared
sample.get_id -> fastapi.Depends
sample.get_id -> fastapi.Depends.query
  • 2.2.0:
.sample -> database.depends.get_db_read
.sample -> fastapi.Depends
sample.get_id -> fastapi.Depends.query

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