Skip to content

Commit

Permalink
change the version (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-probert authored Sep 14, 2024
1 parent 9462b14 commit b90d403
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 197 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
.PHONY: lint
lint:
@echo Linting code
@pre-commit run ruff -a
@poetry run pre-commit run -a

.PHONY: test
test:
Expand Down
48 changes: 24 additions & 24 deletions image_handler_client/schemas/image_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@


class ImageStatus(Enum):
UNVERIFIED = "unverified"
VERIFIED = "verified"
REJECTED = "rejected"
UNVERIFIED = "unverified"
VERIFIED = "verified"
REJECTED = "rejected"


@dataclass(frozen=True)
class ImageInfo:
filename: str
date: int
theme: str
real: bool
status: Optional[ImageStatus] = ImageStatus.UNVERIFIED
filename: str
date: int
theme: str
real: bool
status: Optional[ImageStatus] = ImageStatus.UNVERIFIED


class ImageInfoSchema(Schema):
filename = fields.Str(required=True)
date = fields.Int(required=True)
theme = fields.Str(required=True)
real = fields.Bool(required=True)
status = fields.Field(required=False, load_default=ImageStatus.UNVERIFIED.value)

@post_load
def make_image_info(self, data, **kwargs):
data['status'] = ImageStatus(data['status'])
return ImageInfo(**data)

@post_dump
def convert_status_to_str(self, data, **kwargs):
if 'status' in data and isinstance(data['status'], ImageStatus):
data['status'] = data['status'].value
return data
filename = fields.Str(required=True)
date = fields.Int(required=True)
theme = fields.Str(required=True)
real = fields.Bool(required=True)
status = fields.Field(required=False, load_default=ImageStatus.UNVERIFIED.value)

@post_load
def make_image_info(self, data, **kwargs):
data["status"] = ImageStatus(data["status"])
return ImageInfo(**data)

@post_dump
def convert_status_to_str(self, data, **kwargs):
if "status" in data and isinstance(data["status"], ImageStatus):
data["status"] = data["status"].value
return data


IMAGE_INFO_SCHEMA = ImageInfoSchema()
Loading

0 comments on commit b90d403

Please sign in to comment.