ambitious-student-81104
09/17/2021, 5:58 PME ImportError: cannot import name 'xxx' from 'xxxmodule' (path/to/xxx.py)
It will be much more helpful if the error actually says "circular dependency detected: file name 1, file name 2"hundreds-father-404
09/17/2021, 6:03 PMif TYPE_CHECKING:
import my_circular_dependency
(Which is how you handle circular deps with MyPy type hints, that the cycle only happens when type checking which MyPy can handle, but not prod.)
--
Would you want to always ban cycles no matter what? Or be able to control it more fine-grained, like some files can opt-into cycle tolerance?witty-crayon-22786
09/17/2021, 6:36 PMwitty-crayon-22786
09/17/2021, 6:36 PMambitious-student-81104
09/17/2021, 6:37 PMambitious-student-81104
09/17/2021, 6:38 PMlooks like you have a circular dependency: A-> B -> A
witty-crayon-22786
09/17/2021, 6:48 PMwitty-crayon-22786
09/17/2021, 6:48 PMwitty-crayon-22786
09/17/2021, 6:49 PMwitty-crayon-22786
09/17/2021, 6:49 PMambitious-student-81104
09/17/2021, 6:50 PMlegal in cases where you’ve used conditional imports (likewise, other languages like Java allow import cycles)we typically encourage people to write imports only at file top level. This is much more readable. Most conditional imports can be resolved by re-structuring the code, which ends up in more readable, top-level import only code
witty-crayon-22786
09/17/2021, 6:50 PMwitty-crayon-22786
09/17/2021, 6:50 PMhundreds-father-404
09/17/2021, 6:51 PMhundreds-father-404
09/17/2021, 6:52 PMwitty-crayon-22786
09/17/2021, 6:52 PMwitty-crayon-22786
09/17/2021, 6:53 PMwitty-crayon-22786
09/17/2021, 6:54 PMdependencies
in BUILD
files, or are you mostly using dependency inference?ambitious-student-81104
09/17/2021, 6:54 PMwitty-crayon-22786
09/17/2021, 6:54 PMambitious-student-81104
09/17/2021, 6:54 PMdependencies=[...]
witty-crayon-22786
09/17/2021, 6:55 PMambitious-student-81104
09/17/2021, 7:43 PMhappy-kitchen-89482
09/17/2021, 11:10 PMhundreds-carpet-28072
02/27/2024, 5:01 PMhappy-kitchen-89482
02/27/2024, 9:30 PMhappy-kitchen-89482
02/27/2024, 9:32 PMhundreds-carpet-28072
02/28/2024, 10:47 AMpython_distribution
targets it would be useful to identify cycles between distributed packages, not necessarily their source files, as this could inform defining distributions and prevent pip conflicts. If that makes sense?