Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python reference implementation with builtin annotations #400

Open
Archento opened this issue May 30, 2024 · 0 comments
Open

Update Python reference implementation with builtin annotations #400

Archento opened this issue May 30, 2024 · 0 comments
Labels
c-chore Category: Updates that do not fit into a specific category p-low Priority: Low Priority task

Comments

@Archento
Copy link
Member

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
@Archento Archento added p-low Priority: Low Priority task c-chore Category: Updates that do not fit into a specific category labels Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-chore Category: Updates that do not fit into a specific category p-low Priority: Low Priority task
Projects
None yet
Development

No branches or pull requests

1 participant