matejcik is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
matejcik @matejcik

how is it that I'm running into circular imports so much?

Apparently it's something I didn't have to solve before now. I think what I end up doing is a little ugly, but also it feels like the right way?

· Web · 0 · 0

example:

module `transport` has an `__init__.py` that defines base class `Transport`. It also has `TRANSPORTS` which is a list of all subclasses of `Transport`.

In the init, i'm importing FooTransport, BarTransport, etc. All of those also import the base class from init.

so I moved the subclass imports after the main class definition, and it solves the problem! except it's really, really weird

i could also move the superclass definition to a `common.py` or something, but that feels needless