fetchai/uAgents

Update Python reference implementation with builtin annotations

Opened this issue · 0 comments

Current situation

For a couple of months now we have dropped support for Python3.8 and officially support Python3.9 to 3.12

According to the following two PEPs it is generally recommended since Python3.7 to introduce a proper way of function annotations which was finally enforced in Python3.9.
PEP 563 – Postponed Evaluation of Annotations
PEP 585 – Type Hinting Generics In Standard Collections

Further static typing as defined by PEPs 484, 526, 544, 560, and 563 was built incrementally on top of the existing Python runtime and constrained by existing syntax and runtime behaviour. This led to the existence of a duplicated collection hierarchy in the typing module due to generics (for example typing.List and the built-in list).

The second PEP proposes to enable support for the generics syntax in all standard collections currently available in the typing module.
It removes the necessity for a parallel type hierarchy in the typing module, making it easier for users to annotate their programs.

Requested change

Since this change is mandatory from Python3.9 onwards and also because the list of types this concerns is going to be removed from the typing library at around October 2025 I propose to pro-actively switch to the new builtin syntax.

The following types are affected:

  • tuple # typing.Tuple
  • list # typing.List
  • dict # typing.Dict
  • set # typing.Set
  • frozenset # typing.FrozenSet
  • type # typing.Type
  • collections.deque
  • collections.defaultdict
  • collections.OrderedDict
  • collections.Counter
  • collections.ChainMap
  • collections.abc.Awaitable
  • collections.abc.Coroutine
  • collections.abc.AsyncIterable
  • collections.abc.AsyncIterator
  • collections.abc.AsyncGenerator
  • collections.abc.Iterable
  • collections.abc.Iterator
  • collections.abc.Generator
  • collections.abc.Reversible
  • collections.abc.Container
  • collections.abc.Collection
  • collections.abc.Callable
  • collections.abc.Set # typing.AbstractSet
  • collections.abc.MutableSet
  • collections.abc.Mapping
  • collections.abc.MutableMapping
  • collections.abc.Sequence
  • collections.abc.MutableSequence
  • collections.abc.ByteString
  • collections.abc.MappingView
  • collections.abc.KeysView
  • collections.abc.ItemsView
  • collections.abc.ValuesView
  • contextlib.AbstractContextManager # typing.ContextManager
  • contextlib.AbstractAsyncContextManager # typing.AsyncContextManager
  • re.Pattern # typing.Pattern, typing.re.Pattern
  • re.Match # typing.Match, typing.re.Match