Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
7941b93a
Commit
7941b93a
authored
Mar 04, 2019
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing return type annotation to generators and coroutines.
Closes GH-2884.
parent
61505ce4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
1 deletion
+24
-1
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-1
tests/run/cython3.pyx
tests/run/cython3.pyx
+8
-0
tests/run/generators_py35.py
tests/run/generators_py35.py
+11
-0
No files found.
CHANGES.rst
View file @
7941b93a
...
...
@@ -14,6 +14,9 @@ Bugs fixed
*
Casting
a
GIL
-
requiring
function
into
a
nogil
function
now
issues
a
warning
.
(
Github
issue
#
2879
)
*
Generators
and
coroutines
were
missing
their
return
type
annotation
.
(
Github
issue
#
2884
)
0.29.6
(
2019
-
02
-
27
)
===================
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
7941b93a
...
...
@@ -2624,7 +2624,8 @@ class MarkClosureVisitor(CythonTransform):
pos
=
node
.
pos
,
name
=
node
.
name
,
args
=
node
.
args
,
star_arg
=
node
.
star_arg
,
starstar_arg
=
node
.
starstar_arg
,
doc
=
node
.
doc
,
decorators
=
node
.
decorators
,
gbody
=
gbody
,
lambda_name
=
node
.
lambda_name
)
gbody
=
gbody
,
lambda_name
=
node
.
lambda_name
,
return_type_annotation
=
node
.
return_type_annotation
)
return
coroutine
def
visit_CFuncDefNode
(
self
,
node
):
...
...
tests/run/cython3.pyx
View file @
7941b93a
...
...
@@ -551,3 +551,11 @@ def annotation_syntax(a: "test new test", b : "other" = 2, *args: "ARGS", **kwar
result
:
int
=
a
+
b
return
result
async
def
async_def_annotations
(
x
:
'int'
)
->
'float'
:
"""
>>> sorted(async_def_annotations.__annotations__.items())
[('return', 'float'), ('x', 'int')]
"""
return
float
(
x
)
tests/run/generators_py35.py
View file @
7941b93a
...
...
@@ -22,3 +22,14 @@ def with_outer_raising(*args):
yield
i
raise
StopIteration
return
generator
def
anno_gen
(
x
:
'int'
)
->
'float'
:
"""
>>> gen = anno_gen(2)
>>> next(gen)
2.0
>>> sorted(anno_gen.__annotations__.items())
[('return', 'float'), ('x', 'int')]
"""
yield
float
(
x
)
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