(
        self, name: str, root_project_name: str, package: Optional[str]
    )
return candidates.last()
Find a macro in the graph by its name and package name, or None for
        any package. The root project name is used to determine priority:
         - locally defined macros come first
         - then imported macros
         - then macros defined in the root project
Find a macro in the graph by its name and package name, or None for
        any package. The root project name is used to determine priority:
         - locally defined macros come first
         - then imported macros
         - then macros defined in the root project
Find a macro in the graph by its name and package name or None for any package . The root project name is used to determine priority : - locally defined macros come first - then imported macros - then macros defined in the root project
def find_macro_by_name(
        self, name: str, root_project_name: str, package: Optional[str]
    ) -> Optional[ParsedMacro]:
        """Find a macro in the graph by its name and package name, or None for
        any package. The root project name is used to determine priority:
         - locally defined macros come first
         - then imported macros
         - then macros defined in the root project
        """
        filter: Optional[Callable[[MacroCandidate], bool]] = None
        if package is not None:
            def filter(candidate: MacroCandidate) -> bool:
                return package == candidate.macro.package_name

        candidates: CandidateList = self._find_macros_by_name(
            name=name,
            root_project_name=root_project_name,
            filter=filter,
        )

        return candidates.last()
def find_macro_by_name ( self , name : str , root_project_name : str , package : Optional [ str ] ) -> Optional [ ParsedMacro ] : filter : Optional [ Callable [ [ MacroCandidate ] , bool ] ] = None if package is not None : def filter ( candidate : MacroCandidate ) -> bool : return package == candidate . macro . package_name candidates : CandidateList = self . _find_macros_by_name ( name = name , root_project_name = root_project_name , filter = filter , ) return candidates . last ( )