Skip to content

Use modern Python type annotation syntax #1033

@scotts

Description

@scotts

We still use the old syntax and types. For example, we say something like:

def foo(x: Optional[List[Union[int, float]]]):

While the newer way would be:

def foo(x: list[int | float] | None):

Using list versus List is supported since Python 3.9, and the better optional and union syntax since 3.10. Our minimum has been 3.10 since TorchCodec v0.8. See: https://docs.python.org/3/library/typing.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorImproves code itself, but does not fix a bug or add new functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions