Skip to content

Commit 214abf3

Browse files
committed
update for python 3.10 and higher
1 parent 4f9d5d1 commit 214abf3

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

docs/python/design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ Despite the availability of the `asyncio` library and the `async`/`await` keywor
617617

618618
{% include requirement/MUST id="python-client-sync-async" %} provide both sync and async versions of your APIs
619619

620-
{% include requirement/MUST id="python-client-async-keywords" %} use the `async`/`await` keywords. Do not use the [yield from coroutine or asyncio.coroutine](https://docs.python.org/3.4/library/asyncio-task.html) syntax.
620+
{% include requirement/MUST id="python-client-async-keywords" %} use the `async`/`await` keywords. Do not use the [yield from coroutine or asyncio.coroutine](https://docs.python.org/3.10/library/asyncio-task.html) syntax.
621621

622622
{% include requirement/MUST id="python-client-separate-sync-async" %} provide two separate client classes for synchronous and asynchronous operations. Do not combine async and sync operations in the same class.
623623

docs/python/implementation.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ azure.exampleservice.some_internal_module
547547
{% include requirement/MUST id="python-codestyle-use-builtin-generics" %} use built-in generic types (`list`, `dict`, `tuple`, `set`) in type annotations instead of their `typing` module counterparts (`typing.List`, `typing.Dict`, `typing.Tuple`, `typing.Set`). This is supported as of Python 3.9 ([PEP 585](https://www.python.org/dev/peps/pep-0585/)).
548548

549549
```python
550-
# Yes (Python 3.9+):
550+
# Yes (Python 3.10+):
551551
def get_things() -> list[str]: ...
552552
def get_mapping() -> dict[str, int]: ...
553553

@@ -557,19 +557,15 @@ def get_things() -> List[str]: ...
557557
def get_mapping() -> Dict[str, int]: ...
558558
```
559559

560-
{% include requirement/MUST id="python-codestyle-union-optional" %} use `typing.Union` and `typing.Optional` for union types.
561-
562-
<!-- NOTE: If the minimum supported Python version is raised to 3.10+, use the `X | Y` union syntax
563-
(PEP 604) instead of `typing.Union[X, Y]` and `X | None` instead of `typing.Optional[X]`.
564-
For example: `def foo(x: int | str) -> str | None: ...` -->
560+
{% include requirement/MUST id="python-codestyle-union-optional" %} use the `X | Y` union syntax ([PEP 604](https://www.python.org/dev/peps/pep-0604/)) instead of `typing.Union[X, Y]`, and `X | None` instead of `typing.Optional[X]`. This is supported as of Python 3.10.
565561

566562
```python
567-
# Yes (Python 3.9):
563+
# Yes (Python 3.10+):
564+
def foo(x: int | str) -> str | None: ...
565+
566+
# No:
568567
from typing import Optional, Union
569568
def foo(x: Union[int, str]) -> Optional[str]: ...
570-
571-
# No (requires Python 3.10+):
572-
def foo(x: int | str) -> str | None: ...
573569
```
574570

575571
### Threading

0 commit comments

Comments
 (0)