Skip to content

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

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

Closed
Andrewq11 opened this issue Aug 20, 2024 · 0 comments · Fixed by #281
Closed

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

Andrewq11 opened this issue Aug 20, 2024 · 0 comments · Fixed by #281

Comments

@Andrewq11
Copy link
Contributor

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
@roselynh100 roselynh100 linked a pull request Apr 8, 2025 that will close this issue
5 tasks
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 a pull request may close this issue.

1 participant