Skip to content
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
5 changes: 3 additions & 2 deletions python/copilot/generated/session_events.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions scripts/codegen/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2538,8 +2538,9 @@ export function generatePythonSessionEventsCode(schema: JSONSchema7): string {
out.push(`def to_timedelta_int(x: timedelta) -> int:`);
out.push(` assert isinstance(x, timedelta)`);
out.push(` milliseconds = x.total_seconds() * 1000.0`);
out.push(` assert milliseconds.is_integer()`);
out.push(` return int(milliseconds)`);
out.push(` # Durations can carry sub-millisecond precision; round to the nearest whole ms`);
out.push(` # using Python's default banker's rounding (round-half-to-even).`);
out.push(` return round(milliseconds)`);
Comment on lines 2538 to +2543

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we care about such precision here, so bankers rounding is fine.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should probably update the comment to reflect that it's not rounding to the nearest whole ms though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the comment. Thanks.

out.push(``);
out.push(``);
}
Expand Down
Loading