Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve stubs in av.container #1318

Merged
merged 4 commits into from
Mar 5, 2024

Conversation

laggykiller
Copy link
Contributor

No description provided.

self,
codec_name: str,
rate: Fraction | int | float,
template: Stream,
Copy link
Member

Choose a reason for hiding this comment

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

Should be template: Stream | None = None

Copy link
Contributor Author

@laggykiller laggykiller Mar 5, 2024

Choose a reason for hiding this comment

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

I see that either codec_name or template is needed. Should I type it as an overload function instead?

Edit: Nevermind, typing as overload function would make it impossible to type:

    @overload
    def add_stream(
        self,
        codec_name: str,
        rate: Fraction | int | float | None = None,
        template: None = None,
        options: dict[str, str] | None = None,
    ) -> Stream: ...
    @overload
    def add_stream(
        self,
        codec_name: None,
        rate: Fraction | int | float | None = None,
        template: Stream,
        options: dict[str, str] | None = None,
    ) -> Stream: ...

The second overload function template argument must be provided, but it would cause non-default argument coming after default argument, which is invalid

Copy link
Member

Choose a reason for hiding this comment

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

Yes, overload is appropriate here

Copy link
Contributor Author

@laggykiller laggykiller Mar 5, 2024

Choose a reason for hiding this comment

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

Sorry I edited the previous comment, I found out that typing as overloading might be impossible. Any thoughts?

@WyattBlue WyattBlue merged commit a7202a7 into PyAV-Org:main Mar 5, 2024
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