Skip to content

Import Cycles #2926

Answered by erictraut
lovetox asked this question in Q&A
Discussion options

You must be logged in to vote

Runtime cycle detection is not generally possible to detect statically. It depends on temporal ordering of imports and symbol accesses.

Pyright's cycle detection was designed to detect architectural layering violations. In well-designed programs, modules should generally be strictly layered. If module A imports from module B, there should be no use of types defined in module A within module B. If there are, the code should be refactored to move the common types into the "lower" module or into some common module that is "lower" than both A and B.

This form of cycle detection may report some cases that do not result in runtime cycle violations.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lovetox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants