Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make subrecipients into JSON explicitly #355

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/src/lib/workbook_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def validate_workbook(workbook: Workbook) -> Tuple[Errors, Optional[str]]:
projects, subrecipients, version_string
)


subrecipients = [subrecipient.model_dump() for subrecipient in subrecipients]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the "supported" way in the latest version of Pydantic, see docs

I tested by hardcoding the same results object we use in validate_workbook in workbook_validator and running unit tests, then inspecting the output. json.dumps works and subrecipient output looks good
Screenshot 2024-07-08 at 8 26 06 PM


return (errors, project_use_code, subrecipients)


Expand Down
2 changes: 1 addition & 1 deletion python/src/schemas/schema_V2024_04_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from src.schemas.project_types import NAME_BY_PROJECT


class StateAbbreviation(Enum):
class StateAbbreviation(str, Enum):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subclassing str for an Enum is a quick fix to make it JSON serializable

AL = "AL"
AK = "AK"
AZ = "AZ"
Expand Down
2 changes: 1 addition & 1 deletion python/src/schemas/schema_V2024_05_24.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from src.schemas.project_types import NAME_BY_PROJECT


class StateAbbreviation(Enum):
class StateAbbreviation(str, Enum):
AL = "AL"
AK = "AK"
AZ = "AZ"
Expand Down
Loading