Skip to content

Return AVRational instead of fractions.Fraction - #2382

Merged
WyattBlue merged 3 commits into
mainfrom
patch
Aug 16, 2026
Merged

Return AVRational instead of fractions.Fraction#2382
WyattBlue merged 3 commits into
mainfrom
patch

Conversation

@WyattBlue

Copy link
Copy Markdown
Member

Delete avrational_to_fraction(), the last thing in PyAV producing a Fraction, and route its call sites through from_avrational. Rational attributes now hand back an AVRational, never None. An unset value is the falsy AVRational(0, 1)

Settable attributes are stubbed as property/setter pairs so a fractions.Fraction is still accepted on assignment, as documented, while reads are typed AVRational. The reflected arithmetic dunders gain overloads, without which ctx.framerate = 1 / ctx.time_base fails to type check on the float arm of their return union.

Delete `avrational_to_fraction()`, the last thing in PyAV producing a
Fraction, and route its call sites through from_avrational. Rational
attributes now hand back an AVRational, never None. An unset value is
the falsy `AVRational(0, 1)`

Settable attributes are stubbed as property/setter pairs so a
`fractions.Fraction` is still accepted on assignment, as documented,
while reads are typed AVRational. The reflected arithmetic dunders gain
overloads, without which `ctx.framerate = 1 / ctx.time_base` fails to
type check on the float arm of their return union.
@WyattBlue
WyattBlue merged commit 939d06c into main Aug 16, 2026
8 checks passed
@WyattBlue
WyattBlue deleted the patch branch August 16, 2026 15:33
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