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

Update type annotations to use pipe | for union types #18

Open
ryanhill1 opened this issue Oct 15, 2024 · 6 comments
Open

Update type annotations to use pipe | for union types #18

ryanhill1 opened this issue Oct 15, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ryanhill1
Copy link
Member

Since this project is restricted to Python 3.10 and above, we can take advantage of the newer, preferred syntax for combined types using the pipe (|) operator in type annotations. This syntax is more concise and replaces the need for Union from the typing module.

For example:

from typing import Union

def validate(program: Union[openqasm3.ast.Program, str]) -> None:

can now be simplified to:

def validate(program: openqasm3.ast.Program | str) -> None:

We should apply this updated syntax to all instances where Union is used.

@ryanhill1 ryanhill1 added enhancement New feature or request good first issue Good for newcomers labels Oct 15, 2024
@mthomsonbrown
Copy link

Just browsing open issues on github and this project looks pretty interesting. I wouldn't mind taking on this enhancement. I haven't pulled the project yet, but I love me some syntax optimization!

@TheGupta2012
Copy link
Contributor

@mthomsonbrown go ahead, you're very welcome!

@mthomsonbrown
Copy link

Cool! I'll get an environment set up and hopefully tackle it this weekend.

@ryanhill1
Copy link
Member Author

@mthomsonbrown Still interested in this?

@mthomsonbrown
Copy link

Sorry, I got bogged down with some other stuff. If you want it to get done soon, go ahead and reassign.

@ryanhill1
Copy link
Member Author

@mthomsonbrown No rush on it! Just checking. Not urgent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants