1,882 questions
766
votes
16
answers
1.2m
views
What can I do about "ImportError: Cannot import name X" or "AttributeError: ... (most likely due to a circular import)"?
I have some code spread across multiple files that try to import from each other, as follows:
main.py:
from entity import Ent
entity.py:
from physics import Physics
class Ent:
...
physics.py:
...
494
votes
12
answers
334k
views
Resolve build errors due to circular dependency amongst classes
I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else :) ) which lead to circular dependencies ...
220
votes
3
answers
238k
views
How to avoid circular imports in Python? [duplicate]
I know the issue of circular imports in python has come up many times before and I have read these discussions. The comment that is made repeatedly in these discussions is that a circular import is a ...
161
votes
8
answers
207k
views
Why do circular imports seemingly work further up in the call stack but then raise an ImportError further down?
I'm getting this error
Traceback (most recent call last):
File "/Users/alex/dev/runswift/utils/sim2014/simulator.py", line 3, in <module>
from world import World
File "/...
97
votes
7
answers
97k
views
Circular import dependency in Python [duplicate]
Let's say I have the following directory structure:
a\
__init__.py
b\
__init__.py
c\
__init__.py
c_file.py
d\
__init__.py
...
73
votes
3
answers
31k
views
Dependency diagram in Dart/Flutter?
Is there a way to see how libraries in my Flutter package depend on each other?
Under libraries, I mean internal libraries, dart files under 'lib'.
Also, it would be great to check for circular ...
54
votes
8
answers
96k
views
Why don't include guards make a circular #include work?
I have three classes: GameEvents, Physics and GameObject. I have headers for each of them.
GameEvents has one Physics and a list of GameObjects.
Physics has a list of GameObjects.
Note the circular ...
51
votes
4
answers
88k
views
How to resolve cyclic dependency in Maven?
How can we resolve a Maven cyclic dependency?
Suppose A is the parent project and B and C are child projects. If B is dependent on C and C is dependent on B, is there any way to resolve the cyclic ...
46
votes
5
answers
87k
views
Circular dependency in Java constructors
I have the following classes.
public class B
{
public A a;
public B()
{
a= new A();
System.out.println("Creating B");
}
}
and
public class A
{
public B b;
...
45
votes
8
answers
40k
views
Are circular references acceptable in database?
When are circular references acceptable in database?
Theoretical and practical, any help is appreciated.
42
votes
7
answers
22k
views
Game Objects Talking To Each Other [closed]
What is a good way of dealing with objects and having them talk to each other?
Up until now all my games hobby/student have been small so this problem was generally solved in a rather ugly way, which ...
39
votes
7
answers
19k
views
Circular References Cause Memory Leak?
I'm trying to run down a memory leak in a windows forms application. I'm looking now at a form which contains several embedded forms. What worries me is that the child forms, in their constructor, ...
39
votes
3
answers
23k
views
Resolving circular dependencies by linking the same library twice?
We have a code base broken up into static libraries. Unfortunately, the libraries have circular dependencies; e.g., libfoo.a depends on libbar.a and vice-versa.
I know the "correct" way to handle ...
34
votes
5
answers
119k
views
WARNING in Circular dependency detected - Angular Cli
https://github.com/angular/angular-cli/pull/6813 Added warnings for circular dependencies, and I know I can turn off all warnings using "showCircularDependencies": false. But I would rather keep the ...
29
votes
4
answers
23k
views
Detecting circular imports
I'm working with a project that contains about 30 unique modules. It wasn't designed too well, so it's common that I create circular imports when adding some new functionality to the project.
Of ...
28
votes
5
answers
10k
views
Resolving circular imports in celery and django
I have a Django app that uses Celery to offload some tasks. Mainly, it defers the computation of some fields in a database table.
So, I have a tasks.py:
from models import MyModel
from celery import ...
28
votes
5
answers
40k
views
FastAPI / Pydantic circular references in separate files
I would love to use a schema that looks something like the following in FastAPI:
from __future__ import annotations
from typing import List
from pydantic import BaseModel
class Project(BaseModel):
...
26
votes
4
answers
122k
views
What is a circular dependency and how can I solve it?
Scenario
I have a solution on which I have (more than) 2 projects.
The first project has a project reference to the second project. The second project doesn't have a reference to the first project.
...
25
votes
3
answers
35k
views
Dependency Injection circular dependency .NET Core 2.0
I want my ApplicationContext constructor to have the UserManager as a parameter, but I am having trouble with dependency injection.
Code:
public class ApplicationContext : IdentityDbContext<...
25
votes
6
answers
21k
views
Cannot connect to MongoDB because of wrong URI
I was trying to run mongoDB on node server
Full Code here from MongoDB:
My mongo version: 4.4.3
Node version: v15.7.0
I've imported get started code from MongoDB, and here's the code:
const { ...
24
votes
5
answers
6k
views
OO design and circular dependencies
I am currently struggling with a circular dependency problem when designing my classes.
Ever since I read about the Anemic Domain Model (something I was doing all the time), I have really been ...
22
votes
2
answers
4k
views
circular generic type parameters
I have 2 generic classes, a BaseComponent Class, and a BaseManager class.
They're both abstract and are intended to be made concrete.
public abstract class BaseManager<T> where T : ...
20
votes
9
answers
78k
views
A circular reference has been detected when serializing the object of class "App\Entity\User" (configured limit: 1)
I am faced with a problem that gives me this error:
A circular reference has been detected when serializing the object of
class "App\Entity\User" (configured limit: 1)
I have an Enterprise ...
20
votes
5
answers
19k
views
Python module dependency
Ok I have two modules, each containing a class, the problem is their classes reference each other.
Lets say for example I had a room module and a person module containing CRoom and CPerson.
The ...
20
votes
1
answer
7k
views
Is it possible to import flask configuration values in modules without circular import?
I'm using Flask with Blueprints to get a skeleton for my website and I'm having a problem using configuration classes deep in my application.
Here's some dummy code that explains how I've set ...