How can I implement th following code structure. class A gets an instance of class B but B must be able to call back to A. currenly A won't run because B is not defined yet. but when i swap them B compains that A is not defined yet. I'fighting the python inheritance here and I'm feeling there must be a good solution to this problem. preferrabley one wich remains the references both fom A to B and B to A.
class A:
def __init__(self, b: B):
self.b = b
class B:
def __init__(self):
self.a = None # Will be filled later