Azure / Azure/typespec-azure

Support New Python Union Typing Style

Open
#4,337 0 comments 0 reactions 1 assignee Claimed by @msyyc View on GitHub
emitter:python feature
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 21h
Merged PRs (30d)
164

Description

Since Python 3.10 is now officially the min supported version, we should generate code using the new union operator https://docs.python.org/3/whatsnew/3.10.html#pep-604-new-type-union-operator

The new syntax is visually cleaner and offers a better IDE experience as well.

```python
def square(number: Union[int, float]) -> Union[int, float]:
return number ** 2
```

new syntax
```python
def square(number: int | float) -> int | float:
return number ** 2
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.