Skip to content

Fix to_timedelta_int comment to accurately describe banker's rounding#1676

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-code
Draft

Fix to_timedelta_int comment to accurately describe banker's rounding#1676
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-review-comment-code

Conversation

Copilot AI commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The comment on to_timedelta_int claimed it rounds "to the nearest whole ms," which is misleading — Python's round() uses banker's rounding (round-half-to-even), not conventional 0.5-up rounding.

Changes

  • scripts/codegen/python.ts / python/copilot/generated/session_events.py: Replace assert milliseconds.is_integer() + int() cast with round(), and update the comment to explicitly note banker's rounding semantics:
def to_timedelta_int(x: timedelta) -> int:
    assert isinstance(x, timedelta)
    milliseconds = x.total_seconds() * 1000.0
    # Durations can carry sub-millisecond precision; round to the nearest whole ms
    # using Python's default banker's rounding (round-half-to-even).
    return round(milliseconds)

Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code based on review comment Fix to_timedelta_int comment to accurately describe banker's rounding Jun 15, 2026
Copilot AI requested a review from patniko June 15, 2026 16:57
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