Skip to content

Replace the use of Union with | when defining type annotations #179

@Andrewq11

Description

@Andrewq11

Context

We currently use the Union export from the typing module to define type annotations where more than one type is acceptable. This works, but for more complicated type annotations, using Union makes the code more difficult to read and understand relative to |.

As of python 3.10, the | operator works as Union would but with a simpler syntax. This can improve code readability significantly in some scenarios.

Description

Because the minimum version of python that polaris-lib supports is 3.10, we should embrace the use of the pipe operator rather than the Union type hint.

Acceptance Criteria

  • Redefine all types where Union is used to leverage the | operator instead
  • Ensure all types do not change after the replacement and resolve to the same type annotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions