-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Use HardSoftScore.parse, make Employee attributes optional
- Loading branch information
1 parent
6238ea1
commit 77ca693
Showing
3 changed files
with
20 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,7 @@ def validate_score(v: Any, info: ValidationInfo) -> Any: | |
if isinstance(v, HardSoftScore) or v is None: | ||
return v | ||
if isinstance(v, str): | ||
hard_part, soft_part = v.split('/') | ||
hard = int(hard_part.rstrip('hard')) | ||
soft = int(soft_part.rstrip('soft')) | ||
return HardSoftScore.of(hard, soft) | ||
return HardSoftScore.parse(v) | ||
raise ValueError('"score" should be a string') | ||
|
||
|
||
|
@@ -34,10 +31,10 @@ class BaseSchema(BaseModel): | |
|
||
class Employee(BaseSchema): | ||
name: Annotated[str, PlanningId] | ||
skills: set[str] | ||
unavailable_dates: set[date] | ||
undesired_dates: set[date] | ||
desired_dates: set[date] | ||
skills: Annotated[set[str], Field(default_factory=set)] | ||
unavailable_dates: Annotated[set[date], Field(default_factory=set)] | ||
undesired_dates: Annotated[set[date], Field(default_factory=set)] | ||
desired_dates: Annotated[set[date], Field(default_factory=set)] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Christopher-Chianelli
Author
Contributor
|
||
|
||
|
||
@planning_entity | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Christopher-Chianelli without this, it does run for me in the UI when I click the solve button. Do we need this?