I am working on a project and have run into an issue with circular imports
creation.py
from questions.survey_question import SurveyQuestion, QuestionType
from questions.text_question import TextQuestion
survey_question.py
from questions.text_question import TextQuestion
text_question.py
from questions.survey_question import SurveyQuestion, QuestionType
The reason for this design choice is that TextQuestion inherits SurveyQuestion
And in survey_question.py I have a helper function that takes a list of question entries from my database and turns them into the proper subclass of SurveyQuestion
async def from_db(row) -> SurveyQuestion:
if row["type"] == QuestionType.TEXT:
return await TextQuestion.load(row)
How can I avoid Circular Imports?
I looked at #1293650536834531428 but it did not seem to help