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
9db397c5
Commit
9db397c5
authored
Aug 05, 2015
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix trailing ws.
parent
cd2ac97d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Doc/library/typing.rst
Doc/library/typing.rst
+9
-9
No files found.
Doc/library/typing.rst
View file @
9db397c5
...
@@ -47,8 +47,8 @@ For example::
...
@@ -47,8 +47,8 @@ For example::
on_error: Callable[[int, Exception], None]) -> None:
on_error: Callable[[int, Exception], None]) -> None:
# Body
# Body
It is possible to declare the return type of a callable without specifying
It is possible to declare the return type of a callable without specifying
the call signature by substituting a literal ellipsis
the call signature by substituting a literal ellipsis
for the list of arguments in the type hint: `Callable[..., ReturnType]`.
for the list of arguments in the type hint: `Callable[..., ReturnType]`.
`None` as a type hint is a special case and is replaced by `type(None)`.
`None` as a type hint is a special case and is replaced by `type(None)`.
...
@@ -182,7 +182,7 @@ Default argument values
...
@@ -182,7 +182,7 @@ Default argument values
Use a literal ellipsis `...` to declare an argument as having a default value::
Use a literal ellipsis `...` to declare an argument as having a default value::
from typing import AnyStr
from typing import AnyStr
def foo(x: AnyStr, y: AnyStr = ...) -> AnyStr: ...
def foo(x: AnyStr, y: AnyStr = ...) -> AnyStr: ...
...
@@ -277,14 +277,14 @@ The module defines the following classes, functions and decorators:
...
@@ -277,14 +277,14 @@ The module defines the following classes, functions and decorators:
.. class:: Tuple
.. class:: Tuple
Tuple type; `Tuple[X, Y]` is the is the type of a tuple of two items
Tuple type; `Tuple[X, Y]` is the is the type of a tuple of two items
with the first item of type X and the second of type Y.
with the first item of type X and the second of type Y.
Example: `Tuple[T1, T2]` is a tuple of two elements corresponding
Example: `Tuple[T1, T2]` is a tuple of two elements corresponding
to type variables T1 and T2. `Tuple[int, float, str]` is a tuple
to type variables T1 and T2. `Tuple[int, float, str]` is a tuple
of an int, a float and a string.
of an int, a float and a string.
To specify a variable-length tuple of homogeneous type,
To specify a variable-length tuple of homogeneous type,
use literal ellipsis, e.g. `Tuple[int, ...]`.
use literal ellipsis, e.g. `Tuple[int, ...]`.
.. class:: Callable
.. class:: Callable
...
@@ -296,9 +296,9 @@ The module defines the following classes, functions and decorators:
...
@@ -296,9 +296,9 @@ The module defines the following classes, functions and decorators:
must be a list of types; the return type must be a single type.
must be a list of types; the return type must be a single type.
There is no syntax to indicate optional or keyword arguments,
There is no syntax to indicate optional or keyword arguments,
such function types are rarely used as callback types.
such function types are rarely used as callback types.
`Callable[..., ReturnType]` could be used to type hint a callable
`Callable[..., ReturnType]` could be used to type hint a callable
taking any number of arguments and returning `ReturnType`.
taking any number of arguments and returning `ReturnType`.
A plain `Callable` is equivalent to `Callable[..., Any]`.
A plain `Callable` is equivalent to `Callable[..., Any]`.
.. class:: Generic
.. class:: Generic
...
@@ -322,7 +322,7 @@ The module defines the following classes, functions and decorators:
...
@@ -322,7 +322,7 @@ The module defines the following classes, functions and decorators:
try:
try:
return mapping[key]
return mapping[key]
except KeyError:
except KeyError:
return default
return default
.. class:: Iterable(Generic[T_co])
.. class:: Iterable(Generic[T_co])
...
...
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