8000 bpo-38605: Make postponed evaluation of annotations default by isidentical · Pull Request #20434 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-38605: Make postponed evaluation of annotation 8000 s default #20434

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

Merged
merged 18 commits into from
Oct 6, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Tweak what's new words
  • Loading branch information
gvanrossum authored Oct 6, 2020
commit 1e73aa72331cc6be5ec31d7dd93784072b8360bb
20 changes: 11 additions & 9 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ New Features
PEP 563: Postponed Evaluation of Annotations Becomes Default
------------------------------------------------------------

In Python 3.7, postponed evaluation of annotations added, to be enabled with
``from __future__ import annotations`` directive. In 3.10 this became the
default behavior, even without that future directive. With this being default
all annotations stored in :attr:`__annotations__` will be strings. If needed,
annotations can be resolved at runtime using :func:`typing.get_type_hints`.
Also, the :func:`inspect.signature` will try to resolve types from now on,
and when it fails it will fall back to showing the string annotations. See
:pep:`563` for a full description. (Contributed by Batuhan Taskaya in
:issue:`38605`.)
In Python 3.7, postponed evaluation of annotations was added,
to be enabled with a ``from __future__ import annotations``
directive. In 3.10 this became the default behavior, even
without that future directive. With this being default, all
annotations stored in :attr:`__annotations__` will be strings.
If needed, annotations can be resolved at runtime using
:func:`typing.get_type_hints`. See :pep:`563` for a full
description. Also, the :func:`inspect.signature` will try to
resolve types from now on, and when it fails it will fall back to
showing the string annotations. (Contributed by Batuhan Taskaya
in :issue:`38605`.)

* The :class:`int` type has a new method :meth:`int.bit_count`, returning the
number of ones in the binary expansion of a given integer, also known
Expand Down
0