misc_py310

 1from typing import Dict
 2
 3
 4def new_union(a: int | dict[str, "Foo"]) -> bool | None:
 5    """Testing Python 3.10's new type union syntax."""
 6
 7
 8class Foo:
 9    pass
10
11
12NewStyleDict = dict[str, str]
13"""New-style dict."""
14
15OldStyleDict = Dict[str, str]
16"""Old-style dict."""
def new_union(a: int | dict[str, Foo]) -> bool | None:
5def new_union(a: int | dict[str, "Foo"]) -> bool | None:
6    """Testing Python 3.10's new type union syntax."""

Testing Python 3.10's new type union syntax.

class Foo:
 9class Foo:
10    pass
NewStyleDict = dict[str, str]

New-style dict.

OldStyleDict = typing.Dict[str, str]

Old-style dict.