1

I have two classes from two different files.

I want to use type hints to make it easier to use.

from b import ClassB

# a.py
class ClassA():
    b: ClassB
    def __init__(self):
        self.b = None
from a import ClassA

# b.py
class ClassB():
    a: ClassA
    def __init__(self):
        self.a = None

But I run into a circular dependency problem

this doesn't work either because ClassA is not defined in this file

# b.py
class ClassB():
    a: "ClassA"
    def __init__(self):
        self.a = None
rafalou38
  • 576
  • 1
  • 5
  • 16
  • 1
    Or rather this: [Type hints: solve circular dependency](https://stackoverflow.com/questions/33837918/type-hints-solve-circular-dependency) – mkrieger1 Nov 09 '20 at 17:46
  • 1
    I'm not sure what [from \_\_future\_\_ import annotations](https://stackoverflow.com/questions/61544854/from-future-import-annotations) is supposed to have to do with this. – mkrieger1 Nov 09 '20 at 17:48

0 Answers0