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
039b25d8
Kaydet (Commit)
039b25d8
authored
Eyl 24, 2017
tarafından
topper-123
Kaydeden (comit)
Mariatta
Eyl 24, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31564: Update typing documentation (GH-3696)
Mention that ``NewType`` can derive from another ``NewType``.
üst
d6238a76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
typing.rst
Doc/library/typing.rst
+9
-3
No files found.
Doc/library/typing.rst
Dosyayı görüntüle @
039b25d8
...
@@ -111,8 +111,7 @@ More precisely, the expression ``some_value is Derived(some_value)`` is always
...
@@ -111,8 +111,7 @@ More precisely, the expression ``some_value is Derived(some_value)`` is always
true at runtime.
true at runtime.
This also means that it is not possible to create a subtype of ``Derived``
This also means that it is not possible to create a subtype of ``Derived``
since it is an identity function at runtime, not an actual type. Similarly, it
since it is an identity function at runtime, not an actual type::
is not possible to create another :func:`NewType` based on a ``Derived`` type::
from typing import NewType
from typing import NewType
...
@@ -121,9 +120,16 @@ is not possible to create another :func:`NewType` based on a ``Derived`` type::
...
@@ -121,9 +120,16 @@ is not possible to create another :func:`NewType` based on a ``Derived`` type::
# Fails at runtime and does not typecheck
# Fails at runtime and does not typecheck
class AdminUserId(UserId): pass
class AdminUserId(UserId): pass
# Also does not typecheck
However, it is possible to create a :func:`NewType` based on a 'derived' ``NewType``::
from typing import NewType
UserId = NewType('UserId', int)
ProUserId = NewType('ProUserId', UserId)
ProUserId = NewType('ProUserId', UserId)
and typechecking for ``ProUserId`` will work as expected.
See :pep:`484` for more details.
See :pep:`484` for more details.
.. note::
.. note::
...
...
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