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
d673810b
Kaydet (Commit)
d673810b
authored
May 19, 2019
tarafından
Lysandros Nikolaou
Kaydeden (comit)
Łukasz Langa
May 19, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-35252: Remove FIXME from test_functools (GH-10551)
üst
287b84de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
9 deletions
+11
-9
functools.py
Lib/functools.py
+5
-3
test_functools.py
Lib/test/test_functools.py
+5
-6
2019-04-02-19-23-12.bpo-35252.VooTVv.rst
...S.d/next/Library/2019-04-02-19-23-12.bpo-35252.VooTVv.rst
+1
-0
No files found.
Lib/functools.py
Dosyayı görüntüle @
d673810b
...
@@ -861,9 +861,11 @@ def singledispatch(func):
...
@@ -861,9 +861,11 @@ def singledispatch(func):
# only import typing if annotation parsing is necessary
# only import typing if annotation parsing is necessary
from
typing
import
get_type_hints
from
typing
import
get_type_hints
argname
,
cls
=
next
(
iter
(
get_type_hints
(
func
)
.
items
()))
argname
,
cls
=
next
(
iter
(
get_type_hints
(
func
)
.
items
()))
assert
isinstance
(
cls
,
type
),
(
if
not
isinstance
(
cls
,
type
):
f
"Invalid annotation for {argname!r}. {cls!r} is not a class."
raise
TypeError
(
)
f
"Invalid annotation for {argname!r}. "
f
"{cls!r} is not a class."
)
registry
[
cls
]
=
func
registry
[
cls
]
=
func
if
cache_token
is
None
and
hasattr
(
cls
,
'__abstractmethods__'
):
if
cache_token
is
None
and
hasattr
(
cls
,
'__abstractmethods__'
):
cache_token
=
get_cache_token
()
cache_token
=
get_cache_token
()
...
...
Lib/test/test_functools.py
Dosyayı görüntüle @
d673810b
...
@@ -2355,9 +2355,6 @@ class TestSingleDispatch(unittest.TestCase):
...
@@ -2355,9 +2355,6 @@ class TestSingleDispatch(unittest.TestCase):
))
))
self
.
assertTrue
(
str
(
exc
.
exception
)
.
endswith
(
msg_suffix
))
self
.
assertTrue
(
str
(
exc
.
exception
)
.
endswith
(
msg_suffix
))
# FIXME: The following will only work after PEP 560 is implemented.
return
with
self
.
assertRaises
(
TypeError
)
as
exc
:
with
self
.
assertRaises
(
TypeError
)
as
exc
:
@i.register
@i.register
def
_
(
arg
:
typing
.
Iterable
[
str
]):
def
_
(
arg
:
typing
.
Iterable
[
str
]):
...
@@ -2366,10 +2363,12 @@ class TestSingleDispatch(unittest.TestCase):
...
@@ -2366,10 +2363,12 @@ class TestSingleDispatch(unittest.TestCase):
# types from `typing`. Instead, annotate with regular types
# types from `typing`. Instead, annotate with regular types
# or ABCs.
# or ABCs.
return
"I annotated with a generic collection"
return
"I annotated with a generic collection"
self
.
assertTrue
(
str
(
exc
.
exception
)
.
startswith
(
msg_prefix
+
self
.
assertTrue
(
str
(
exc
.
exception
)
.
startswith
(
"<function TestSingleDispatch.test_invalid_registrations.<locals>._"
"Invalid annotation for 'arg'."
))
self
.
assertTrue
(
str
(
exc
.
exception
)
.
endswith
(
'typing.Iterable[str] is not a class.'
))
))
self
.
assertTrue
(
str
(
exc
.
exception
)
.
endswith
(
msg_suffix
))
def
test_invalid_positional_argument
(
self
):
def
test_invalid_positional_argument
(
self
):
@functools.singledispatch
@functools.singledispatch
...
...
Misc/NEWS.d/next/Library/2019-04-02-19-23-12.bpo-35252.VooTVv.rst
0 → 100644
Dosyayı görüntüle @
d673810b
Throw a TypeError instead of an AssertionError when using an invalid type annotation with singledispatch.
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