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
80490525
Commit
80490525
authored
Jan 16, 2017
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #29011: Fix an important omission by adding Deque to the typing module.
parent
a105dd3d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
4 deletions
+41
-4
Doc/library/typing.rst
Doc/library/typing.rst
+4
-0
Lib/test/test_typing.py
Lib/test/test_typing.py
+11
-0
Lib/typing.py
Lib/typing.py
+10
-0
Misc/NEWS
Misc/NEWS
+16
-4
No files found.
Doc/library/typing.rst
View file @
80490525
...
...
@@ -557,6 +557,10 @@ The module defines the following classes, functions and decorators:
As a shorthand for this type, :class:`bytes` can be used to
annotate arguments of any of the types mentioned above.
.. class:: Deque(deque, MutableSequence[T])
A generic version of :class:`collections.deque`.
.. class:: List(list, MutableSequence[T])
Generic version of :class:`list`.
...
...
Lib/test/test_typing.py
View file @
80490525
...
...
@@ -1572,6 +1572,9 @@ class CollectionsAbcTests(BaseTestCase):
def
test_list
(
self
):
self
.
assertIsSubclass
(
list
,
typing
.
List
)
def
test_deque
(
self
):
self
.
assertIsSubclass
(
collections
.
deque
,
typing
.
Deque
)
def
test_set
(
self
):
self
.
assertIsSubclass
(
set
,
typing
.
Set
)
self
.
assertNotIsSubclass
(
frozenset
,
typing
.
Set
)
...
...
@@ -1642,6 +1645,14 @@ class CollectionsAbcTests(BaseTestCase):
self
.
assertIsSubclass
(
MyDefDict
,
collections
.
defaultdict
)
self
.
assertNotIsSubclass
(
collections
.
defaultdict
,
MyDefDict
)
def
test_no_deque_instantiation
(
self
):
with
self
.
assertRaises
(
TypeError
):
typing
.
Deque
()
with
self
.
assertRaises
(
TypeError
):
typing
.
Deque
[
T
]()
with
self
.
assertRaises
(
TypeError
):
typing
.
Deque
[
int
]()
def
test_no_set_instantiation
(
self
):
with
self
.
assertRaises
(
TypeError
):
typing
.
Set
()
...
...
Lib/typing.py
View file @
80490525
...
...
@@ -59,6 +59,7 @@ __all__ = [
'SupportsRound'
,
# Concrete collection types.
'Deque'
,
'Dict'
,
'DefaultDict'
,
'List'
,
...
...
@@ -1771,6 +1772,15 @@ class List(list, MutableSequence[T], extra=list):
"use list() instead"
)
return
_generic_new
(
list
,
cls
,
*
args
,
**
kwds
)
class
Deque
(
collections
.
deque
,
MutableSequence
[
T
],
extra
=
collections
.
deque
):
__slots__
=
()
def
__new__
(
cls
,
*
args
,
**
kwds
):
if
_geqv
(
cls
,
Deque
):
raise
TypeError
(
"Type Deque cannot be instantiated; "
"use deque() instead"
)
return
_generic_new
(
collections
.
deque
,
cls
,
*
args
,
**
kwds
)
class
Set
(
set
,
MutableSet
[
T
],
extra
=
set
):
...
...
Misc/NEWS
View file @
80490525
...
...
@@ -2,6 +2,18 @@
Python
News
+++++++++++
What
's New in Python 3.5.4?
===========================
Core and Builtins
-----------------
Library
-------
- Issue #29011: Fix an important omission by adding Deque to the typing module.
What'
s
New
in
Python
3.5.3
?
===========================
...
...
@@ -528,17 +540,17 @@ Library
- Issue #27972: Prohibit Tasks to await on themselves.
-
Issue
#
26923
:
Fix
asyncio
.
Gather
to
refuse
being
cancelled
once
all
- Issue #26923: Fix asyncio.Gather to refuse being cancelled once all
children are done.
Patch by Johannes Ebke.
-
Issue
#
26796
:
Don
't configure the number of workers for default
- Issue #26796: Don'
t
configure
the
number
of
workers
for
default
threadpool
executor
.
Initial
patch
by
Hans
Lawrenz
.
-
Issue
#
28600
:
Optimize
loop
.
call_soon
().
- Issue #28613: Fix get_event_loop() return the current loop if
-
Issue
#
28613
:
Fix
get_event_loop
()
return
the
current
loop
if
called
from
coroutines
/
callbacks
.
-
Issue
#
28639
:
Fix
inspect
.
isawaitable
to
always
return
bool
...
...
@@ -553,7 +565,7 @@ Library
-
Issue
#
24142
:
Reading
a
corrupt
config
file
left
the
parser
in
an
invalid
state
.
Original
patch
by
Florian
H
ö
ch
.
- Issue #28990: Fix SSL hanging if connection is closed before handshake
-
Issue
#
28990
:
Fix
SSL
hanging
if
connection
is
closed
before
handshake
completed
.
(
Patch
by
HoHo
-
Ho
)
...
...
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