mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 06:28:50 +00:00
feat: use XDG directory standards
Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
This commit is contained in:
parent
9736f096f6
commit
407c3e3bad
50 changed files with 5611 additions and 508 deletions
|
@ -10,14 +10,15 @@ Type-safe data interchange for Python data classes.
|
|||
:see: https://github.com/hunyadi/strong_typing
|
||||
"""
|
||||
|
||||
from typing import Callable, Dict, Iterable, List, Optional, Set, TypeVar
|
||||
from collections.abc import Callable, Iterable
|
||||
from typing import TypeVar
|
||||
|
||||
from .inspection import TypeCollector
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def topological_sort(graph: Dict[T, Set[T]]) -> List[T]:
|
||||
def topological_sort(graph: dict[T, set[T]]) -> list[T]:
|
||||
"""
|
||||
Performs a topological sort of a graph.
|
||||
|
||||
|
@ -29,9 +30,9 @@ def topological_sort(graph: Dict[T, Set[T]]) -> List[T]:
|
|||
"""
|
||||
|
||||
# empty list that will contain the sorted nodes (in reverse order)
|
||||
ordered: List[T] = []
|
||||
ordered: list[T] = []
|
||||
|
||||
seen: Dict[T, bool] = {}
|
||||
seen: dict[T, bool] = {}
|
||||
|
||||
def _visit(n: T) -> None:
|
||||
status = seen.get(n)
|
||||
|
@ -57,8 +58,8 @@ def topological_sort(graph: Dict[T, Set[T]]) -> List[T]:
|
|||
|
||||
def type_topological_sort(
|
||||
types: Iterable[type],
|
||||
dependency_fn: Optional[Callable[[type], Iterable[type]]] = None,
|
||||
) -> List[type]:
|
||||
dependency_fn: Callable[[type], Iterable[type]] | None = None,
|
||||
) -> list[type]:
|
||||
"""
|
||||
Performs a topological sort of a list of types.
|
||||
|
||||
|
@ -78,7 +79,7 @@ def type_topological_sort(
|
|||
graph = collector.graph
|
||||
|
||||
if dependency_fn:
|
||||
new_types: Set[type] = set()
|
||||
new_types: set[type] = set()
|
||||
for source_type, references in graph.items():
|
||||
dependent_types = dependency_fn(source_type)
|
||||
references.update(dependent_types)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue