Registry / serialization / cyclic

cyclic

JSON →
library1.0.0pypypi✓ verified 86d ago

The `cyclic` Python library, currently at version 1.0.0, is designed to handle and detect cyclic relations between objects. It allows you to add parent-child relationships and then query if a specific object is part of a cyclic dependency. The library has a low release cadence, with its last update in 2018.

pip install cyclic
INSTALL
IMPORT
SIG · CYCLIC
C
cyclic
serializationpythonv1.0.0
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Cyclic
from cyclic import Cyclic

This quickstart demonstrates how to initialize the `Cyclic` checker, add parent-child relationships, and then use `is_cyclic()` to determine if an object is part of a cyclic dependency. It shows a clear example of how to introduce and detect a cycle.

from cyclic import Cyclic # Initialize the Cyclic checker cy = Cyclic() # Let's define some objects (can be anything hashable) A = 'Object A' B = 'Object B' C = 'Object C' D = 'Object D' # Add relationships: A is parent of B, B is parent of C cy.add(B, A) cy.add(C, B) # Check for cycles (C -> B -> A, no cycle yet) print(f"Is C in a cyclic relation? {cy.is_cyclic(C)}") # Introduce a cycle: C is parent of A (now A -> B -> C -> A) cy.add(A, C) # Check for cycles again print(f"Is C now in a cyclic relation? {cy.is_cyclic(C)}") print(f"Is A now in a cyclic relation? {cy.is_cyclic(A)}") # Adding a non-cyclic relationship to D cy.add(D, C) print(f"Is D in a cyclic relation? {cy.is_cyclic(D)}")
Debug
Known issues
gotchaThe `cyclic` library is designed to *detect* circular dependencies based on added relationships, not to prevent Python's own circular import errors during module loading. If you encounter `ImportError` due to modules importing each other, this library will not resolve that underlying architectural issue.
fix
For Python circular import issues, refactor your module structure to break the dependency cycle (e.g., move shared code to a common module, use lazy imports, or reorganize responsibilities).
affects: 1.0.0
deprecatedThe `cyclic` library has not been updated since 2018. While it appears stable for its specific use case, its long-term maintenance and compatibility with very recent Python versions (beyond 3.6/3.7 for which it was likely current) are uncertain. Consider this when integrating into new projects.
fix
Assess the stability and compatibility in your specific Python environment. For new projects requiring robust dependency management, evaluate more actively maintained alternatives or be prepared to fork and maintain the library yourself.
affects: All versions (1.0.0)
Errors
Common errors & fixes
from cyclic import Cyclic; ModuleNotFoundError: No module named 'cyclic'
The `cyclic` package has not been installed in your Python environment.
fix
Run `pip install cyclic` to install the package.
AttributeError: 'Cyclic' object has no attribute 'add_relation' (or similar method name)
Incorrect method name used. The primary method for adding relationships is `add(child, parent)`.
fix
Use the correct method `cy.add(child_object, parent_object)` to establish a dependency.
TypeError: unhashable type: 'list' (or other mutable type) when using `add()` or `is_cyclic()`
The `cyclic` library internally uses sets for tracking relationships, requiring that the objects involved in dependencies (both child and parent) are hashable. Mutable types like lists or dictionaries are not hashable by default.
fix
Ensure that the objects you are tracking with `cyclic.Cyclic` are immutable and thus hashable (e.g., strings, numbers, tuples, or custom objects with a `__hash__` method). If you need to track mutable objects, use a unique immutable identifier for each object instead.
Upgrade
Version history
1.0.0latest on PyPI · released Sep 26, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
cyclic — pip install cyclic · libregistry