Skip to content

Commit

Permalink
refactor: improve imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Mala1180 committed Apr 26, 2024
1 parent 85065b2 commit 858804c
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 68 deletions.
5 changes: 2 additions & 3 deletions application/question_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from domain.graph.core.project_id import ProjectId
from domain.graph.core.question import Question
from domain.graph.repositories.question_repository import QuestionRepository
from domain.graph.core import ProjectId, Question
from domain.graph.repositories import QuestionRepository


class QuestionService:
Expand Down
2 changes: 1 addition & 1 deletion domain/graph/core/answer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from domain.graph.core.answer_id import AnswerId
from domain.graph.core import AnswerId


class Answer(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion domain/graph/core/project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from domain.graph.core.project_id import ProjectId
from domain.graph.core import ProjectId


class Project(BaseModel):
Expand Down
6 changes: 2 additions & 4 deletions domain/graph/core/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

from pydantic import BaseModel, field_serializer

from domain.graph.core.answer import Answer
from domain.graph.core.question_id import QuestionId
from domain.graph.core.enum.action import Action
from domain.graph.core.enum.question_type import QuestionType
from domain.graph.core import Answer, QuestionId
from domain.graph.core.enum import Action, QuestionType


class Question(BaseModel):
Expand Down
3 changes: 1 addition & 2 deletions domain/graph/factories/answer_factory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from domain.graph.core.answer import Answer
from domain.graph.core.answer_id import AnswerId
from domain.graph.core.answer import Answer, AnswerId


class AnswerFactory:
Expand Down
3 changes: 1 addition & 2 deletions domain/graph/factories/project_factory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from domain.graph.core.project import Project
from domain.graph.core.project_id import ProjectId
from domain.graph.core import Project, ProjectId


class ProjectFactory:
Expand Down
34 changes: 15 additions & 19 deletions domain/graph/factories/question_factory.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from typing import FrozenSet, Optional

from domain.graph.core.answer import Answer
from domain.graph.core.answer_id import AnswerId
from domain.graph.core.enum.action import Action
from domain.graph.core.enum.question_type import QuestionType
from domain.graph.core.question import Question
from domain.graph.core.question_id import QuestionId
from domain.graph.factories.answer_factory import AnswerFactory
from domain.graph.core import Answer, AnswerId, QuestionId, Question
from domain.graph.core.enum import Action, QuestionType
from domain.graph.factories import AnswerFactory


class QuestionFactory:
Expand All @@ -15,13 +11,13 @@ def __init__(self):
self._answer_factory = AnswerFactory()

def create_question(
self,
question_id: QuestionId,
text: str,
question_type: QuestionType,
available_answers: FrozenSet[Answer],
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
self,
question_id: QuestionId,
text: str,
question_type: QuestionType,
available_answers: FrozenSet[Answer],
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
) -> Question:
return Question(
id=question_id,
Expand All @@ -33,11 +29,11 @@ def create_question(
)

def create_boolean_question(
self,
question_id: QuestionId,
text: str,
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
self,
question_id: QuestionId,
text: str,
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
) -> Question:
available_answers: FrozenSet[Answer] = frozenset(
{
Expand Down
4 changes: 1 addition & 3 deletions domain/graph/repositories/question_repository.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from abc import ABC, abstractmethod
from typing import List

from domain.graph.core.project_id import ProjectId
from domain.graph.core.question import Question
from domain.graph.core.question_id import QuestionId
from domain.graph.core import ProjectId, QuestionId, Question


class QuestionRepository(ABC):
Expand Down
5 changes: 2 additions & 3 deletions domain/project/core/selectable_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from pydantic import field_serializer
from typing_extensions import Self

from domain.graph.core.answer import Answer
from domain.graph.core.question import Question
from domain.project.core.selection.selection_strategy import SelectionStrategy
from domain.graph.core import Answer, Question
from domain.project.core.selection import SelectionStrategy


class SelectableQuestion(Question):
Expand Down
8 changes: 6 additions & 2 deletions domain/project/core/selection/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from domain.project.core.selection.selection_strategy import SelectionStrategy
from domain.project.core.selection.multiple_selection_strategy import MultipleSelectionStrategy
from domain.project.core.selection.single_selection_strategy import SingleSelectionStrategy
from domain.project.core.selection.multiple_selection_strategy import (
MultipleSelectionStrategy,
)
from domain.project.core.selection.single_selection_strategy import (
SingleSelectionStrategy,
)
4 changes: 2 additions & 2 deletions domain/project/core/selection/multiple_selection_strategy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing_extensions import FrozenSet

from domain.graph.core.answer import Answer
from domain.project.core.selection.selection_strategy import SelectionStrategy
from domain.graph.core import Answer
from domain.project.core.selection import SelectionStrategy


class MultipleSelectionStrategy(SelectionStrategy):
Expand Down
2 changes: 1 addition & 1 deletion domain/project/core/selection/selection_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pydantic import BaseModel
from typing_extensions import FrozenSet

from domain.graph.core.answer import Answer
from domain.graph.core import Answer


class SelectionStrategy(ABC, BaseModel):
Expand Down
4 changes: 3 additions & 1 deletion domain/project/factories/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from domain.project.factories.selectable_question_factory import SelectableQuestionFactory
from domain.project.factories.selectable_question_factory import (
SelectableQuestionFactory,
)
43 changes: 21 additions & 22 deletions domain/project/factories/selectable_question_factory.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from typing import FrozenSet, Optional

from domain.graph.core.answer import Answer
from domain.graph.core.answer_id import AnswerId
from domain.graph.core.enum.action import Action
from domain.graph.core.enum.question_type import QuestionType
from domain.graph.core.question_id import QuestionId
from domain.graph.factories.answer_factory import AnswerFactory
from domain.project.core.selectable_question import SelectableQuestion
from domain.project.core.selection.multiple_selection_strategy import MultipleSelectionStrategy
from domain.project.core.selection.single_selection_strategy import SingleSelectionStrategy
from domain.graph.core import Answer, AnswerId, QuestionId
from domain.graph.core.enum import Action, QuestionType
from domain.graph.factories import AnswerFactory
from domain.project.core import SelectableQuestion
from domain.project.core.selection import (
MultipleSelectionStrategy,
SingleSelectionStrategy,
)


class SelectableQuestionFactory:
Expand All @@ -17,14 +16,14 @@ def __init__(self):
self._answer_factory = AnswerFactory()

def create_question(
self,
question_id: QuestionId,
text: str,
question_type: QuestionType,
available_answers: FrozenSet[Answer],
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
selected_answers: FrozenSet[Answer] = frozenset(),
self,
question_id: QuestionId,
text: str,
question_type: QuestionType,
available_answers: FrozenSet[Answer],
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
selected_answers: FrozenSet[Answer] = frozenset(),
) -> SelectableQuestion:
match question_type:
case QuestionType.BOOLEAN:
Expand All @@ -50,11 +49,11 @@ def create_question(
)

def create_boolean_question(
self,
question_id: QuestionId,
text: str,
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
self,
question_id: QuestionId,
text: str,
previous_question_id: Optional[QuestionId] = None,
action_needed: Optional[Action] = None,
) -> SelectableQuestion:
available_answers: FrozenSet[Answer] = frozenset(
{
Expand Down
3 changes: 1 addition & 2 deletions storage/repositories/graph_question_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from dotenv import load_dotenv
from neo4j import GraphDatabase

from domain.graph.core import ProjectId, QuestionId
from domain.graph.core import Question
from domain.graph.core import ProjectId, QuestionId, Question
from domain.graph.repositories import QuestionRepository
from presentation.presentation import serialize, deserialize

Expand Down

0 comments on commit 858804c

Please sign in to comment.