Skip to content
Open
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
4 changes: 2 additions & 2 deletions webvtt/segmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import typing
import os
import pathlib
from math import ceil, floor
from math import floor

from .webvtt import WebVTT, Caption

Expand Down Expand Up @@ -49,7 +49,7 @@ def slice_segments(
total_segments = (
0
if not captions else
int(ceil(captions[-1].end_in_seconds / seconds))
floor(captions[-1].end_in_seconds / seconds) + 1

Choose a reason for hiding this comment

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

math.floor returns a float, you should still cast this as an int. Tested on my local and this PR resolves the issue.

Copy link
Author

Choose a reason for hiding this comment

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

@reikoshea
Thank you for your feedback. I believe that a cast is unnecessary since the value returned by math.floor is already of integer type. Please see the following example from the Python interpreter:

Python 3.10.16 (main, Apr  8 2025, 14:31:23) [GCC 11.4.0] on linux
>>> import math
>>> math.floor(12.345)
12
>>> type(math.floor(12.345))
<class 'int'>

)

segments: typing.List[typing.List[Caption]] = [
Expand Down