Skip to content

Conversation

Copy link

Copilot AI commented Oct 31, 2025

CI was failing with PydanticSerializationError: Unable to serialize unknown type when serializing DatetimeRangeWithTZColumn models containing tzinfo objects in the time_zones field.

Changes

  • Add field_serializer for time_zones: Converts tzinfo objects to string names via get_tzname() during pydantic serialization
  • Fix error message construction: Convert tuple concatenation to f-string in check_duplicated_time_zones validator
  • Fix hardcoded column name: Use self.time_zone_column instead of literal "time_zone" in TimeZoneConverterByColumn.generate_to_schema()
  • Improve documentation: Replace TODO comments with explanatory comments for get_time_zones() methods that return empty lists
  • Fix typos: Correct 'eactual' → 'actual', 'srd_schema' → 'src_schema', 'will aligned' → 'will be aligned'

Example

from chronify.time_configs import DatetimeRangeWithTZColumn
from zoneinfo import ZoneInfo

config = DatetimeRangeWithTZColumn(
    start=datetime(2020, 1, 1),
    resolution=timedelta(hours=1),
    length=24,
    time_zone_column="tz",
    time_zones=[ZoneInfo("US/Eastern"), None]
)

# Now serializes correctly to:
# {"time_zones": ["US/Eastern", "None"], ...}
config.model_dump()

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add field_serializer for time_zones to fix pydantic serialization of tzinfo objects
- Fix typo: 'eactual' to 'actual' in time_series_checker.py
- Fix typo: 'srd_schema' to 'src_schema' in time_zone_converter.py
- Fix grammar: 'will aligned' to 'will be aligned' in time_zone_converter.py
- Fix error message construction from tuple to f-string in time_configs.py
- Improve TODO comment explanations in time_utils.py and time_configs.py
- Fix hardcoded 'time_zone' to use self.time_zone_column in TimeZoneConverterByColumn

Co-authored-by: daniel-thom <9037606+daniel-thom@users.noreply.github.com>
Copilot AI changed the title [WIP] Add geography tz conversion Fix pydantic serialization of tzinfo objects in DatetimeRangeWithTZColumn Oct 31, 2025
Copilot AI requested a review from daniel-thom October 31, 2025 01:15
@lixiliu
Copy link
Collaborator

lixiliu commented Nov 7, 2025

Not required.

@lixiliu lixiliu closed this Nov 7, 2025
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.

3 participants