Circular Dependency Error case assumes comparable items
Firstly, thanks for the software! Am just hitting a minor issue here.
As per the description, toposort generally only requires hashability (for toposort_flatten, this requires sort=False), but when generating the message for CircularDependencyError it attempts to sort the items which results in the wrong exception being raised and the cycles not being available.
Reproducer:
import toposort
# Make some objects which are hashable, and which can be tested for
# equality but which are not comparable
class A:
pass
class B:
pass
class C:
pass
# Works fine
assert list(toposort.toposort({A: {B}, B: {C}})) == [{C}, {B}, {A}]
# Also - no restrictions
assert list(toposort.toposort({A: set(), B: set(), C: set()})) == [{A, B, C}]
# However, if there is a cycle we don't get the expected exception
# We get TypeError: '<' not supported between instances of 'type' and 'type'
try:
list(toposort.toposort({A: {B}, B: {C}, C: {A}}))
except toposort.CircularDependencyError:
pass