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
4326a3b9
Commit
4326a3b9
authored
Sep 27, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow arbitrary annotations again with "annotation_typing=False", not only valid types.
parent
acd03a26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
tests/run/embedsignatures.pyx
tests/run/embedsignatures.pyx
+5
-6
No files found.
CHANGES.rst
View file @
4326a3b9
...
...
@@ -35,6 +35,9 @@ Bugs fixed
* Cython annotation types in Python files could lead to import failures
with a "cython undefined" error. Recognised types are now turned into strings.
* Annotations could be parsed (and rejected) as types even with
``annotation_typing=False``.
0.27 (2017-09-23)
=================
...
...
Cython/Compiler/Nodes.py
View file @
4326a3b9
...
...
@@ -1657,7 +1657,7 @@ class FuncDefNode(StatNode, BlockNode):
# Annotations can not only contain valid Python expressions but arbitrary type references.
if
annotation
is
None
:
return
None
if
annotation
.
analyse_as_type
(
env
)
is
None
:
if
not
env
.
directives
[
'annotation_typing'
]
or
annotation
.
analyse_as_type
(
env
)
is
None
:
annotation
=
annotation
.
analyse_types
(
env
)
return
annotation
...
...
tests/run/embedsignatures.pyx
View file @
4326a3b9
#cython: embedsignature=True
#cython: embedsignature=True
, annotation_typing=False
import
sys
...
...
@@ -81,7 +81,7 @@ __doc__ = ur"""
Ext.m(self, a=u'spam')
>>> print (Ext.n.__doc__)
Ext.n(self, a: int,
double
b: float = 1.0, *args: tuple, **kwargs: dict) -> (None, True)
Ext.n(self, a: int, b: float = 1.0, *args: tuple, **kwargs: dict) -> (None, True)
>>> print (Ext.get_int.__doc__)
Ext.get_int(self) -> int
...
...
@@ -403,8 +403,7 @@ cdef class Foo:
def
m03
(
self
,
a
:
42
,
b
:
+
42
,
c
:
-
42
)
->
int
:
pass
# XXX +42 -> 42
def
m04
(
self
,
a
:
3.14
,
b
:
+
3.14
,
c
:
-
3.14
)
->
float
:
pass
def
m05
(
self
,
a
:
1
+
2j
,
b
:
+
2j
,
c
:
-
2j
)
->
complex
:
pass
# this is not a valid PEP 484 declaration, and Cython interprets it as a C-tuple
#def m06(self, a: "abc", b: b"abc", c: u"abc") -> (str, bytes, unicode) : pass
def
m06
(
self
,
a
:
"abc"
,
b
:
b"abc"
,
c
:
u"abc"
)
->
(
str
,
bytes
,
unicode
)
:
pass
def
m07
(
self
,
a
:
[
1
,
2
,
3
],
b
:
[])
->
list
:
pass
def
m08
(
self
,
a
:
(
1
,
2
,
3
),
b
:
())
->
tuple
:
pass
def
m09
(
self
,
a
:
{
1
,
2
,
3
},
b
:
{
i
for
i
in
()})
->
set
:
pass
...
...
@@ -449,8 +448,8 @@ Foo.m04(self, a: 3.14, b: 3.14, c: -3.14) -> float
>>> print(Foo.m05.__doc__)
Foo.m05(self, a: 1 + 2j, b: +2j, c: -2j) -> complex
#
>>> print(Foo.m06.__doc__)
#
Foo.m06(self, a: 'abc', b: b'abc', c: u'abc') -> (str, bytes, unicode)
>>> print(Foo.m06.__doc__)
Foo.m06(self, a: 'abc', b: b'abc', c: u'abc') -> (str, bytes, unicode)
>>> print(Foo.m07.__doc__)
Foo.m07(self, a: [1, 2, 3], b: []) -> list
...
...
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