[ILibraryView] child_order shouldn't leak graphlib.CycleErrror
This commit is contained in:
parent
09a95a6608
commit
ae314cce93
2 changed files with 28 additions and 2 deletions
|
|
@ -22,7 +22,7 @@ import copy
|
|||
from pprint import pformat
|
||||
from collections import defaultdict
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from graphlib import TopologicalSorter
|
||||
from graphlib import TopologicalSorter, CycleError
|
||||
|
||||
import numpy
|
||||
from numpy.typing import ArrayLike, NDArray
|
||||
|
|
@ -618,7 +618,13 @@ class ILibraryView(Mapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||
Return:
|
||||
Topologically sorted list of pattern names.
|
||||
"""
|
||||
return cast('list[str]', list(TopologicalSorter(self.child_graph(dangling=dangling)).static_order()))
|
||||
try:
|
||||
return cast('list[str]', list(TopologicalSorter(self.child_graph(dangling=dangling)).static_order()))
|
||||
except CycleError as exc:
|
||||
cycle = exc.args[1] if len(exc.args) > 1 else None
|
||||
if cycle is None:
|
||||
raise LibraryError('Cycle found while building child order') from exc
|
||||
raise LibraryError(f'Cycle found while building child order: {cycle}') from exc
|
||||
|
||||
def find_refs_local(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue