John Snow <js...@redhat.com> writes:

> In this patch, we don't have a builtin type to use for a type hint, but
> we do have collections.abc and other standard library types. Replace
> deprecated type hints with their standard library equivalents:
>
> typing.Awaitable      => collections.abc.Awaitable
> typing.AbstractSet    => collections.abc.AbstractSet
> typing.AsyncIterator  => collections.abc.AsyncIterator
> typing.Callable       => collections.abc.Callable
> typing.Coroutine      => collections.abc.Coroutine
> typing.Deque          => collections.deque
> typing.Generator      => collections.abc.Generator
> typing.Iterable       => collections.abc.Iterable
> typing.Iterator       => collections.abc.Iterator
> typing.Mapping        => collections.abc.Mapping
> typing.Match          => re.Match
> typing.MutableMapping => collections.abc.MutableMapping
> typing.Sequence       => collections.abc.Sequence
> typing.ValuesView     => collections.abc.ValuesView
>
> The primary benefit of this is, of course, that the standard type can
> now be used directly as the type hint. In general, this means far fewer
> imports from `typing`. The reason we *have* to do this is because the
> old type hints have been deprecated and will be dropped from a Python
> release in the future, so I am just getting ahead of it before it causes
> a problem.
>
> (Granted, yes, in practice this just means we're usually importing from
> collections.abc instead of typing, but... ah well. What are you gonna
> do.)
>
> Signed-off-by: John Snow <js...@redhat.com>

I'd expect to catch mistakes in the manual parts.  I gave scripts/qapi/
an eye-over anyway, and it looks good to me.

Acked-by: Markus Armbruster <arm...@redhat.com>

Typing imports left at the end of the series:

    *
    Any
    BinaryIO
    Generic
    IO
    Literal
    NamedTuple
    NewType
    NoReturn
    Optional
    Protocol
    TYPE_CHECKING
    TextIO
    TypeVar
    Union
    cast

The * are in scripts/codeconverter/.  You might want to double-check
nothing deprecated hides behind the *.

The others are all still good, I presume.


Reply via email to