Skip to content

Commit

Permalink
remove unneeded constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Kürten committed Jul 11, 2024
1 parent 8e528dd commit 88b430b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 22 deletions.
8 changes: 1 addition & 7 deletions csfunctions/events/document_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@


class DocumentReleaseData(BaseModel):
def __init__(self, documents: list[Document], parts: list[Part], dialog_data: dict, **kwargs):
super().__init__(documents=documents, parts=parts, dialog_data=dialog_data, **kwargs)

documents: list[Document] = Field(..., description="List of documents that were released.")
parts: list[Part] = Field(..., description="List of parts that belong to the released documents")
dialog_data: DocumentReleaseDialogData


class DocumentReleaseEvent(BaseEvent):
def __init__(self, event_id: str, data: DocumentReleaseData, **_):
super().__init__(name=EventNames.DOCUMENT_RELEASE, event_id=event_id, data=data)

name: Literal[EventNames.DOCUMENT_RELEASE]
name: Literal[EventNames.DOCUMENT_RELEASE] = EventNames.DOCUMENT_RELEASE
data: DocumentReleaseData
5 changes: 1 addition & 4 deletions csfunctions/events/engineering_change_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@ class EngineeringChangeReleaseData(BaseModel):


class EngineeringChangeRelease(BaseEvent):
def __init__(self, event_id: str, data: EngineeringChangeReleaseData, **_):
super().__init__(name=EventNames.ENGINEERING_CHANGE_RELEASE, event_id=event_id, data=data)

name: Literal[EventNames.ENGINEERING_CHANGE_RELEASE]
name: Literal[EventNames.ENGINEERING_CHANGE_RELEASE] = EventNames.ENGINEERING_CHANGE_RELEASE
data: EngineeringChangeReleaseData
8 changes: 1 addition & 7 deletions csfunctions/events/part_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@


class PartReleaseData(BaseModel):
def __init__(self, parts: list[Part], dialog_data: dict, **kwargs):
super().__init__(parts=parts, dialog_data=dialog_data, **kwargs)

parts: list[Part] = Field(..., description="List if parts that were released.")
documents: list[Document] = Field(..., description="List if documents that are referenced by the released part.")
dialog_data: PartReleaseDialogData


class PartReleaseEvent(BaseEvent):
def __init__(self, event_id: str, data: PartReleaseData, **_):
super().__init__(name=EventNames.PART_RELEASE, event_id=event_id, data=data)

name: Literal[EventNames.PART_RELEASE]
name: Literal[EventNames.PART_RELEASE] = EventNames.PART_RELEASE
data: PartReleaseData
6 changes: 3 additions & 3 deletions json_schemas/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@
"properties": {
"name": {
"const": "document_release",
"default": "document_release",
"enum": [
"document_release"
],
Expand All @@ -878,7 +879,6 @@
}
},
"required": [
"name",
"event_id",
"data"
],
Expand Down Expand Up @@ -1256,6 +1256,7 @@
"properties": {
"name": {
"const": "engineering_change_release",
"default": "engineering_change_release",
"enum": [
"engineering_change_release"
],
Expand All @@ -1272,7 +1273,6 @@
}
},
"required": [
"name",
"event_id",
"data"
],
Expand Down Expand Up @@ -2587,6 +2587,7 @@
"properties": {
"name": {
"const": "part_release",
"default": "part_release",
"enum": [
"part_release"
],
Expand All @@ -2603,7 +2604,6 @@
}
},
"required": [
"name",
"event_id",
"data"
],
Expand Down
2 changes: 1 addition & 1 deletion tests/events/test_ec_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_link_objects(self):
data = EngineeringChangeReleaseData(
documents=[document], parts=[part], engineering_changes=[engineering_change]
)
event = EngineeringChangeRelease("123", data)
event = EngineeringChangeRelease(event_id="123", data=data)
request.event = event

# objects are not linked yet
Expand Down

0 comments on commit 88b430b

Please sign in to comment.