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
0a2abdfc
Unverified
Kaydet (Commit)
0a2abdfc
authored
Kas 16, 2017
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Kas 16, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-30143: 2to3 now generates a code that uses abstract collection classes (#1262)
from collections.abc rather than collections.
üst
a7368ac6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
2to3.rst
Doc/library/2to3.rst
+6
-6
fix_operator.py
Lib/lib2to3/fixes/fix_operator.py
+6
-6
test_fixers.py
Lib/lib2to3/tests/test_fixers.py
+4
-4
2017-10-12-19-05-54.bpo-30143.25_hU1.rst
...S.d/next/Library/2017-10-12-19-05-54.bpo-30143.25_hU1.rst
+2
-0
No files found.
Doc/library/2to3.rst
Dosyayı görüntüle @
0a2abdfc
...
...
@@ -345,20 +345,20 @@ and off individually. They are described here in more detail.
Converts calls to various functions in the :mod:`operator` module to other,
but equivalent, function calls. When needed, the appropriate ``import``
statements are added, e.g. ``import collections``. The following mapping
statements are added, e.g. ``import collections
.abc
``. The following mapping
are made:
================================== ==========================================
================================== ==========================================
===
From To
================================== ==========================================
================================== ==========================================
===
``operator.isCallable(obj)`` ``hasattr(obj, '__call__')``
``operator.sequenceIncludes(obj)`` ``operator.contains(obj)``
``operator.isSequenceType(obj)`` ``isinstance(obj, collections.Sequence)``
``operator.isMappingType(obj)`` ``isinstance(obj, collections.Mapping)``
``operator.isSequenceType(obj)`` ``isinstance(obj, collections.
abc.
Sequence)``
``operator.isMappingType(obj)`` ``isinstance(obj, collections.
abc.
Mapping)``
``operator.isNumberType(obj)`` ``isinstance(obj, numbers.Number)``
``operator.repeat(obj, n)`` ``operator.mul(obj, n)``
``operator.irepeat(obj, n)`` ``operator.imul(obj, n)``
================================== ==========================================
================================== ==========================================
===
.. 2to3fixer:: paren
...
...
Lib/lib2to3/fixes/fix_operator.py
Dosyayı görüntüle @
0a2abdfc
...
...
@@ -2,8 +2,8 @@
operator.isCallable(obj) -> hasattr(obj, '__call__')
operator.sequenceIncludes(obj) -> operator.contains(obj)
operator.isSequenceType(obj) -> isinstance(obj, collections.Sequence)
operator.isMappingType(obj) -> isinstance(obj, collections.Mapping)
operator.isSequenceType(obj) -> isinstance(obj, collections.
abc.
Sequence)
operator.isMappingType(obj) -> isinstance(obj, collections.
abc.
Mapping)
operator.isNumberType(obj) -> isinstance(obj, numbers.Number)
operator.repeat(obj, n) -> operator.mul(obj, n)
operator.irepeat(obj, n) -> operator.imul(obj, n)
...
...
@@ -63,13 +63,13 @@ class FixOperator(fixer_base.BaseFix):
def
_irepeat
(
self
,
node
,
results
):
return
self
.
_handle_rename
(
node
,
results
,
"imul"
)
@invocation
(
"isinstance(
%
s, collections.Sequence)"
)
@invocation
(
"isinstance(
%
s, collections.
abc.
Sequence)"
)
def
_isSequenceType
(
self
,
node
,
results
):
return
self
.
_handle_type2abc
(
node
,
results
,
"collections"
,
"Sequence"
)
return
self
.
_handle_type2abc
(
node
,
results
,
"collections
.abc
"
,
"Sequence"
)
@invocation
(
"isinstance(
%
s, collections.Mapping)"
)
@invocation
(
"isinstance(
%
s, collections.
abc.
Mapping)"
)
def
_isMappingType
(
self
,
node
,
results
):
return
self
.
_handle_type2abc
(
node
,
results
,
"collections"
,
"Mapping"
)
return
self
.
_handle_type2abc
(
node
,
results
,
"collections
.abc
"
,
"Mapping"
)
@invocation
(
"isinstance(
%
s, numbers.Number)"
)
def
_isNumberType
(
self
,
node
,
results
):
...
...
Lib/lib2to3/tests/test_fixers.py
Dosyayı görüntüle @
0a2abdfc
...
...
@@ -4427,12 +4427,12 @@ class Test_operator(FixerTestCase):
def
test_operator_isSequenceType
(
self
):
b
=
"operator.isSequenceType(x)"
a
=
"import collections
\n
isinstance(x, collections
.Sequence)"
a
=
"import collections
.abc
\n
isinstance(x, collections.abc
.Sequence)"
self
.
check
(
b
,
a
)
def
test_operator_isMappingType
(
self
):
b
=
"operator.isMappingType(x)"
a
=
"import collections
\n
isinstance(x, collections
.Mapping)"
a
=
"import collections
.abc
\n
isinstance(x, collections.abc
.Mapping)"
self
.
check
(
b
,
a
)
def
test_operator_isNumberType
(
self
):
...
...
@@ -4478,12 +4478,12 @@ class Test_operator(FixerTestCase):
def
test_bare_operator_isSequenceType
(
self
):
s
=
"isSequenceType(z)"
t
=
"You should use 'isinstance(z, collections.Sequence)' here."
t
=
"You should use 'isinstance(z, collections.
abc.
Sequence)' here."
self
.
warns_unchanged
(
s
,
t
)
def
test_bare_operator_isMappingType
(
self
):
s
=
"isMappingType(x)"
t
=
"You should use 'isinstance(x, collections.Mapping)' here."
t
=
"You should use 'isinstance(x, collections.
abc.
Mapping)' here."
self
.
warns_unchanged
(
s
,
t
)
def
test_bare_operator_isNumberType
(
self
):
...
...
Misc/NEWS.d/next/Library/2017-10-12-19-05-54.bpo-30143.25_hU1.rst
0 → 100644
Dosyayı görüntüle @
0a2abdfc
2to3 now generates a code that uses abstract collection classes from
collections.abc rather than collections.
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