Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
A
astor
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
astor
Commits
49a35d8f
Kaydet (Commit)
49a35d8f
authored
Mar 06, 2017
tarafından
Ryan Gonzalez
Kaydeden (comit)
Berker Peksag
Nis 19, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add support for async comprehensions
üst
064c9429
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
CHANGES
CHANGES
+1
-1
code_gen.py
astor/code_gen.py
+2
-0
test_code_gen.py
tests/test_code_gen.py
+12
-2
No files found.
CHANGES
Dosyayı görüntüle @
49a35d8f
...
...
@@ -11,4 +11,4 @@
0.4.1 -- Added missing SourceGenerator.visit_arguments()
0.5 -- Added support for Python 3.5 infix matrix
multiplication
0.6 -- Added support for Python 3.6 f-strings.
0.6 -- Added support for Python 3.6 f-strings
and async comprehensions
.
astor/code_gen.py
Dosyayı görüntüle @
49a35d8f
...
...
@@ -716,6 +716,8 @@ class SourceGenerator(ExplicitNodeVisitor):
def
visit_comprehension
(
self
,
node
):
set_precedence
(
node
,
node
.
iter
,
*
node
.
ifs
)
set_precedence
(
Precedence
.
comprehension_target
,
node
.
target
)
if
getattr
(
node
,
'is_async'
,
False
):
self
.
write
(
' async'
)
self
.
write
(
' for '
,
node
.
target
,
' in '
,
node
.
iter
)
for
if_
in
node
.
ifs
:
self
.
write
(
' if '
,
if_
)
tests/test_code_gen.py
Dosyayı görüntüle @
49a35d8f
...
...
@@ -271,11 +271,11 @@ class CodegenTestCase(unittest.TestCase):
def
test_comprehension
(
self
):
source
=
"""
((x,y) for x,y in zip(a,b))
((x,y) for x,y in zip(a,b)
if a
)
"""
self
.
assertAstEqual
(
source
)
source
=
"""
fields = [(a, _format(b)) for (a, b) in iter_fields(node)]
fields = [(a, _format(b)) for (a, b) in iter_fields(node)
if a
]
"""
self
.
assertAstEqual
(
source
)
source
=
"""
...
...
@@ -284,6 +284,16 @@ class CodegenTestCase(unittest.TestCase):
"""
self
.
assertAstEqual
(
source
)
def
test_async_comprehension
(
self
):
source
=
"""
async def f():
[(await x) async for x in y]
[(await i) for i in b if await c]
(await x async for x in y)
{i for i in b async for i in a if await i for b in i}
"""
self
.
assertAstSourceEqualIfAtLeastVersion
(
source
,
(
3
,
6
))
def
test_tuple_corner_cases
(
self
):
source
=
"""
a = ()
...
...
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