
If this is your own code and have the ability to change it, I recommend refactoring it to eliminate the circular dependency. You can typically do so by combining interdependent types into one module or by creating a common module that abstracts out types that are shared among other modules. It sounds like you were exploring the latter option, and I think that's a worthwhile exploration. The alternative, as others have pointed out, is to use TYPE_CHECKING conditionals to avoid a runtime circular dependency, but this simply masks the fact that you have an architectural cycle in your code — something that I try to avoid in my projects. Ideally, all module dependencies (implied or explicit) should form a DAG. Pyright has an optional check called `reportImportCycles` that performs this analysis and reports an error when a cycle is detected. I enable this check for my team's code bases, and we strictly adhere to the "no architectural cycles" policy. -- Eric Traut Contributor to Pyright and Pylance Microsoft