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

[BUGFIX] Ensure datetime.time can be serialized to JSON #10795

Merged
merged 7 commits into from
Dec 19, 2024

Conversation

wookasz
Copy link
Contributor

@wookasz wookasz commented Dec 19, 2024

Adds datetime.time handling to the serialization code in utils. datetime.time is now serializable, and serialization is performed by converting it to its ISO format string.

  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB]
  • Code is linted - run invoke lint (uses ruff format + ruff check)
  • Appropriate tests and docs have been updated

For more information about contributing, visit our community resources.

After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!

Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for niobium-lead-7998 canceled.

Name Link
🔨 Latest commit c78e86d
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/67647b51bec71a00086d149e

Copy link

codecov bot commented Dec 19, 2024

❌ 180 Tests Failed:

Tests completed Failed Passed Skipped
22332 180 22152 3921
View the top 3 failed tests by shortest run time
::tests.integration.cloud.rest_contracts.test_checkpoints
Stack Traces | 0s run time
No failure message available
::tests.integration.data_sources_and_expectations.expectations.test_expect_column_proportion_of_unique_values_to_be_between
Stack Traces | 0s run time
No failure message available
::tests.integration.data_sources_and_expectations.expectations.test_expect_column_values_to_be_in_set
Stack Traces | 0s run time
No failure message available

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

Comment on lines 562 to 579


@pytest.mark.unit
@pytest.mark.parametrize(
"data", [pytest.param({"t": datetime.time(hour=1, minute=30, second=45)}, id="datetime.time")]
)
def test_convert_to_json_serializable_converts_correctly(data: dict):
ret = convert_to_json_serializable(data)
assert ret == {"t": "01:30:45"}


@pytest.mark.unit
@pytest.mark.parametrize(
"data", [pytest.param({"t": datetime.time(hour=1, minute=30, second=45)}, id="datetime.time")]
)
def test_ensure_json_serializable(data: dict):
ensure_json_serializable(data)
# Passes if no exception raised
Copy link
Member

Choose a reason for hiding this comment

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

tests look good, but they should probably live in tests.test_convert_to_json_serializable, unless there's a compelling reason to break the pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll move. I didn't notice that file assuming we were following the pattern of test file per module

Copy link
Member

Choose a reason for hiding this comment

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

yeah, that would be super reasonable - at some point we could refactor this to be more logical. thanks for addressing!

Copy link
Member

@joshua-stauffer joshua-stauffer left a comment

Choose a reason for hiding this comment

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

looks good, just would recommend writing these tests next to the ones we already ahve

Copy link
Member

@joshua-stauffer joshua-stauffer left a comment

Choose a reason for hiding this comment

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

thanks!

@wookasz wookasz enabled auto-merge December 19, 2024 20:00
@wookasz wookasz added this pull request to the merge queue Dec 19, 2024
Merged via the queue into develop with commit 29a4dba Dec 19, 2024
71 checks passed
@wookasz wookasz deleted the b/_/serialize-time branch December 19, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants