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
a4895997
Kaydet (Commit)
a4895997
authored
Kas 28, 2017
tarafından
Dong-hee Na
Kaydeden (comit)
Éric Araujo
Kas 28, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32046: Update 2to3 when converts operator.isCallable(obj). (#4417)
üst
598ceae8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
+8
-7
2to3.rst
Doc/library/2to3.rst
+1
-1
fix_operator.py
Lib/lib2to3/fixes/fix_operator.py
+3
-4
test_fixers.py
Lib/lib2to3/tests/test_fixers.py
+2
-2
2017-11-16-20-09-45.bpo-32046.9sGDtw.rst
...S.d/next/Library/2017-11-16-20-09-45.bpo-32046.9sGDtw.rst
+2
-0
No files found.
Doc/library/2to3.rst
Dosyayı görüntüle @
a4895997
...
...
@@ -351,7 +351,7 @@ and off individually. They are described here in more detail.
================================== =============================================
From To
================================== =============================================
``operator.isCallable(obj)`` ``
hasattr(obj, '__call__'
)``
``operator.isCallable(obj)`` ``
callable(obj
)``
``operator.sequenceIncludes(obj)`` ``operator.contains(obj)``
``operator.isSequenceType(obj)`` ``isinstance(obj, collections.abc.Sequence)``
``operator.isMappingType(obj)`` ``isinstance(obj, collections.abc.Mapping)``
...
...
Lib/lib2to3/fixes/fix_operator.py
Dosyayı görüntüle @
a4895997
"""Fixer for operator functions.
operator.isCallable(obj) ->
hasattr(obj, '__call__'
)
operator.isCallable(obj) ->
callable(obj
)
operator.sequenceIncludes(obj) -> operator.contains(obj)
operator.isSequenceType(obj) -> isinstance(obj, collections.abc.Sequence)
operator.isMappingType(obj) -> isinstance(obj, collections.abc.Mapping)
...
...
@@ -49,11 +49,10 @@ class FixOperator(fixer_base.BaseFix):
def
_sequenceIncludes
(
self
,
node
,
results
):
return
self
.
_handle_rename
(
node
,
results
,
"contains"
)
@invocation
(
"
hasattr(
%
s, '__call__'
)"
)
@invocation
(
"
callable(
%
s
)"
)
def
_isCallable
(
self
,
node
,
results
):
obj
=
results
[
"obj"
]
args
=
[
obj
.
clone
(),
String
(
", "
),
String
(
"'__call__'"
)]
return
Call
(
Name
(
"hasattr"
),
args
,
prefix
=
node
.
prefix
)
return
Call
(
Name
(
"callable"
),
[
obj
.
clone
()],
prefix
=
node
.
prefix
)
@invocation
(
"operator.mul(
%
s)"
)
def
_repeat
(
self
,
node
,
results
):
...
...
Lib/lib2to3/tests/test_fixers.py
Dosyayı görüntüle @
a4895997
...
...
@@ -4409,7 +4409,7 @@ class Test_operator(FixerTestCase):
def
test_operator_isCallable
(
self
):
b
=
"operator.isCallable(x)"
a
=
"
hasattr(x, '__call__'
)"
a
=
"
callable(x
)"
self
.
check
(
b
,
a
)
def
test_operator_sequenceIncludes
(
self
):
...
...
@@ -4468,7 +4468,7 @@ class Test_operator(FixerTestCase):
def
test_bare_isCallable
(
self
):
s
=
"isCallable(x)"
t
=
"You should use '
hasattr(x, '__call__'
)' here."
t
=
"You should use '
callable(x
)' here."
self
.
warns_unchanged
(
s
,
t
)
def
test_bare_sequenceIncludes
(
self
):
...
...
Misc/NEWS.d/next/Library/2017-11-16-20-09-45.bpo-32046.9sGDtw.rst
0 → 100644
Dosyayı görüntüle @
a4895997
Updates 2to3 to convert from operator.isCallable(obj) to callable(obj).
Patch by Dong-hee Na.
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