Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f6b96c7b
Kaydet (Commit)
f6b96c7b
authored
Ock 17, 2017
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge
üst
b05cbac0
e12c313f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
typing.rst
Doc/library/typing.rst
+4
-0
test_typing.py
Lib/test/test_typing.py
+11
-0
typing.py
Lib/typing.py
+10
-0
No files found.
Doc/library/typing.rst
Dosyayı görüntüle @
f6b96c7b
...
@@ -563,6 +563,10 @@ The module defines the following classes, functions and decorators:
...
@@ -563,6 +563,10 @@ The module defines the following classes, functions and decorators:
As a shorthand for this type, :class:`bytes` can be used to
As a shorthand for this type, :class:`bytes` can be used to
annotate arguments of any of the types mentioned above.
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])
.. class:: List(list, MutableSequence[T])
Generic version of :class:`list`.
Generic version of :class:`list`.
...
...
Lib/test/test_typing.py
Dosyayı görüntüle @
f6b96c7b
...
@@ -1572,6 +1572,9 @@ class CollectionsAbcTests(BaseTestCase):
...
@@ -1572,6 +1572,9 @@ class CollectionsAbcTests(BaseTestCase):
def
test_list
(
self
):
def
test_list
(
self
):
self
.
assertIsSubclass
(
list
,
typing
.
List
)
self
.
assertIsSubclass
(
list
,
typing
.
List
)
def
test_deque
(
self
):
self
.
assertIsSubclass
(
collections
.
deque
,
typing
.
Deque
)
def
test_set
(
self
):
def
test_set
(
self
):
self
.
assertIsSubclass
(
set
,
typing
.
Set
)
self
.
assertIsSubclass
(
set
,
typing
.
Set
)
self
.
assertNotIsSubclass
(
frozenset
,
typing
.
Set
)
self
.
assertNotIsSubclass
(
frozenset
,
typing
.
Set
)
...
@@ -1642,6 +1645,14 @@ class CollectionsAbcTests(BaseTestCase):
...
@@ -1642,6 +1645,14 @@ class CollectionsAbcTests(BaseTestCase):
self
.
assertIsSubclass
(
MyDefDict
,
collections
.
defaultdict
)
self
.
assertIsSubclass
(
MyDefDict
,
collections
.
defaultdict
)
self
.
assertNotIsSubclass
(
collections
.
defaultdict
,
MyDefDict
)
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
):
def
test_no_set_instantiation
(
self
):
with
self
.
assertRaises
(
TypeError
):
with
self
.
assertRaises
(
TypeError
):
typing
.
Set
()
typing
.
Set
()
...
...
Lib/typing.py
Dosyayı görüntüle @
f6b96c7b
...
@@ -59,6 +59,7 @@ __all__ = [
...
@@ -59,6 +59,7 @@ __all__ = [
'SupportsRound'
,
'SupportsRound'
,
# Concrete collection types.
# Concrete collection types.
'Deque'
,
'Dict'
,
'Dict'
,
'DefaultDict'
,
'DefaultDict'
,
'List'
,
'List'
,
...
@@ -1771,6 +1772,15 @@ class List(list, MutableSequence[T], extra=list):
...
@@ -1771,6 +1772,15 @@ class List(list, MutableSequence[T], extra=list):
"use list() instead"
)
"use list() instead"
)
return
_generic_new
(
list
,
cls
,
*
args
,
**
kwds
)
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
):
class
Set
(
set
,
MutableSet
[
T
],
extra
=
set
):
...
...
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