Skip to content

Comments

Auto-generate type hints for OptionsContainer#125

Merged
asrashley merged 11 commits intomainfrom
mps-early-terminated
Feb 23, 2026
Merged

Auto-generate type hints for OptionsContainer#125
asrashley merged 11 commits intomainfrom
mps-early-terminated

Conversation

@asrashley
Copy link
Owner

Rather than using generic dictionary and mapping types to describe all of the DashOption parameters, generate Python and Typescript type definitions.

By using the auto-generated OptionsContainerType data class, there is no need to have functions to generate the default options, nor pass instances of this default between containers. The OptionsContainer class can be used directly. When using the constructor with no arguments, it will be created with the defaults populated.

Alex Ashley added 5 commits February 13, 2026 14:57
The duration attribute of a Period element is optional. When it is
not present, the duration can be calculated from the start of the
next period, or is undefined if this is the last Period.

The validator was incorrectly requiring a duration element. In
addition, when checking SegmentTimeline within a Representation, it
was using total timeshiftBufferDepth, rather than the expected
duration of the Period.
In most cases, there is no need to put in a Period@duration
attribute, as the start of the next Period can be used to calculate
a Period's duration.

A new forcePeriodDurations option ("periodDur" CGI parameter) is added
that allows overriding this default of omitting duration attributes.
the class name had been copied and pasted from the server tests
rather than using generic dictionary and mapping types to describe
all of the DashOptions, generate Python and Typescript type definitions.
Rather than providing a from_string and to_string lambda in each
DashOption, use a set of option classes, that inherit from DashOption,
which perform the conversion to and from strings.

This allows DashOption to use Generic type hints, making it easier
for the type metadata to correctly describe the type of each option.
Alex Ashley added 6 commits February 23, 2026 15:29
By using the auto-generated OptionsContainerType data class, there
is no need to have functions to generate the default options, nor
pass instances of this default between containers. The OptionsContainer
class can be used directly. When using the constructor with no
arguments, it will be created with the defaults populated.
As well as generating type hints for the full option names, generate
them for the short option and CGI options.
The generic map of [string, unknown] can be replaced with the
OptionsContainerType type that describes the type for each property
in the type.
The short options are similar to the CGI options, in that they
are a flat map of unique parameter names.
If an option has a fixed set of strings that are allowed for its
value, this can be more accurately expressed in Typescript than
Python. For example, the "mode" parameter is a str in Python, but
when generating Typescript, this can be "live" | "vod" | "odvod"
@asrashley asrashley force-pushed the mps-early-terminated branch from f7bd113 to e1e5c7b Compare February 23, 2026 15:35
@asrashley asrashley merged commit 676699c into main Feb 23, 2026
7 checks passed
@asrashley asrashley deleted the mps-early-terminated branch February 23, 2026 16:56
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.

1 participant