Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a3291531
Commit
a3291531
authored
Oct 13, 2019
by
Raymond Hettinger
Committed by
GitHub
Oct 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-37759: Add examples for the new typing features (GH-16763)
parent
61a6db5e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
Doc/whatsnew/3.8.rst
Doc/whatsnew/3.8.rst
+21
-5
No files found.
Doc/whatsnew/3.8.rst
View file @
a3291531
...
...
@@ -1048,17 +1048,33 @@ typing
The :mod:`typing` module incorporates several new features:
* Protocol definitions. See :pep:`544`, :class:`typing.Protocol` and
:func:`typing.runtime_checkable`. Simple ABCs like
:class:`typing.SupportsInt` are now ``Protocol`` subclasses.
* A dictionary type with per-key types. See :pep:`589` and
:class:`typing.TypedDict`.
TypedDict uses only string keys. By default, every key is required
to be present. Specify "total=False" to allow keys to be optional::
class Location(TypedDict, total=False):
lat_long: tuple
grid_square: str
xy_coordinate: tuple
* Literal types. See :pep:`586` and :class:`typing.Literal`.
Literal types indicate that a parameter or return value
is constrained to one or more specific literal values::
def get_status(port: int) -> Literal['connected', 'disconnected']:
...
* "Final" variables, functions, methods and classes. See :pep:`591`,
:class:`typing.Final` and :func:`typing.final`.
The final qualifier instructs a static type checker to restrict
subclassing, overriding, or reassignment::
pi: Final[float] = 3.1415926536
* Protocol definitions. See :pep:`544`, :class:`typing.Protocol` and
:func:`typing.runtime_checkable`. Simple ABCs like
:class:`typing.SupportsInt` are now ``Protocol`` subclasses.
* New protocol class :class:`typing.SupportsIndex`.
...
...
@@ -1527,7 +1543,7 @@ Changes in Python behavior
terminate the current thread if called while the interpreter is
finalizing, making them consistent with :c:func:`PyEval_RestoreThread`,
:c:func:`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`. If this
behavio
u
r is not desired, guard the call by checking :c:func:`_Py_IsFinalizing`
behavior is not desired, guard the call by checking :c:func:`_Py_IsFinalizing`
or :c:func:`sys.is_finalizing`.
Changes in the Python API
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment