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
2386a4cb
Commit
2386a4cb
authored
Oct 29, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'annotation_pyi_test' of
https://github.com/smartsammler/cython
into mypy
parents
5e6ca038
682aa7fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
5 deletions
+121
-5
Cython/Shadow.pyi
Cython/Shadow.pyi
+96
-0
runtests.py
runtests.py
+22
-3
test-requirements.txt
test-requirements.txt
+1
-0
tests/run/pure_py3.py
tests/run/pure_py3.py
+2
-2
No files found.
Cython/Shadow.pyi
0 → 100644
View file @
2386a4cb
from builtins import (int as py_int, float as py_float,
bool as py_bool, str as py_str)
from typing import (Union, Dict, Any, Sequence, Optional,
List, TypeVar, Type, Generic)
int = py_int
long = py_int
longlong = py_int
short = py_int
char = py_int
sint = py_int
slong = py_int
slonglong = py_int
sshort = py_int
schar = py_int
uint = py_int
ulong = py_int
ulonglong = py_int
ushort = py_int
uchar = py_int
size_t = py_int
Py_ssize_t = py_int
float = py_float
double = py_float
longdouble = py_float
bint = py_bool
void = Union[None]
basestring = py_str
gs: Dict[str, Any] # Should match the return type of globals()
_T = TypeVar('_T')
class _ArrayType(object, Generic[_T]):
is_array: bool
subtypes: Sequence[str]
dtype: _T
ndim: int
is_c_contig: bool
is_f_contig: bool
inner_contig: bool
broadcasting: Any
# broadcasting is not used, so it's not clear about its type
def __init__(self, dtype: _T, ndim: int, is_c_contig: bool = ...,
is_f_contig: bool = ..., inner_contig: bool = ...,
broadcasting: Any = ...) -> None: ...
def __repr__(self) -> str: ...
class CythonTypeObject(object):
...
class CythonType(CythonTypeObject):
...
class PointerType(CythonType, Generic[_T]):
def __init__(
self,
value: Optional[Union[ArrayType[_T],
PointerType[_T], List[_T], int]] = ...
) -> None: ...
def __getitem__(self, ix: int) -> _T: ...
def __setitem__(self, ix: int, value: _T) -> None: ...
def __eq__(self, value: object) -> bool: ...
def __repr__(self) -> str: ...
class ArrayType(PointerType[_T]):
def __init__(self) -> None: ...
class StructType(CythonType, Generic[_T]):
def __init__(
self,
value: List[Type[_T]] = ...
) -> None: ...
def index_type(
base_type: _T, item: Union[tuple, slice, int]) -> _ArrayType[_T]: ...
def pointer(basetype: _T) -> Type[PointerType[_T]]: ...
def array(basetype: _T, n: int) -> Type[ArrayType[_T]]: ...
def struct(basetype: _T) -> Type[StructType[_T]]: ...
class typedef(CythonType, Generic[_T]):
name: str
def __init__(self, type: _T, name: Optional[str] = ...) -> None: ...
def __call__(self, *arg: Any) -> _T: ...
def __repr__(self) -> str: ...
__getitem__ = index_type
class _FusedType(CythonType, Genergic[_T]):
def __init__(self, Union[py_int, py_long, py_float, py_complex, Any]) -> None: ...
def fused_type(basetype: _T) -> Type[FusedType[_T]]: ...
runtests.py
View file @
2386a4cb
...
@@ -257,7 +257,7 @@ def update_cpp11_extension(ext):
...
@@ -257,7 +257,7 @@ def update_cpp11_extension(ext):
compiler_version = gcc_version.group(1)
compiler_version = gcc_version.group(1)
if float(compiler_version) > 4.8:
if float(compiler_version) > 4.8:
ext.extra_compile_args.extend("-std=c++11")
ext.extra_compile_args.extend("-std=c++11")
return ext
return ext
return EXCLUDE_EXT
return EXCLUDE_EXT
...
@@ -612,7 +612,7 @@ class TestBuilder(object):
...
@@ -612,7 +612,7 @@ class TestBuilder(object):
if pyver
if pyver
]
]
if not min_py_ver or any(sys.version_info >= min_ver for min_ver in min_py_ver):
if not min_py_ver or any(sys.version_info >= min_ver for min_ver in min_py_ver):
suite.addTest(PureDoctestTestCase(module, os.path.join(path, filename)))
suite.addTest(PureDoctestTestCase(module, os.path.join(path, filename)
, tags
))
return suite
return suite
...
@@ -1202,7 +1202,8 @@ def run_forked_test(result, run_func, test_name, fork=True):
...
@@ -1202,7 +1202,8 @@ def run_forked_test(result, run_func, test_name, fork=True):
except: pass
except: pass
class PureDoctestTestCase(unittest.TestCase):
class PureDoctestTestCase(unittest.TestCase):
def __init__(self, module_name, module_path):
def __init__(self, module_name, module_path, tags):
self.tags = tags
self.module_name = module_name
self.module_name = module_name
self.module_path = module_path
self.module_path = module_path
unittest.TestCase.__init__(self, 'run')
unittest.TestCase.__init__(self, 'run')
...
@@ -1235,6 +1236,24 @@ class PureDoctestTestCase(unittest.TestCase):
...
@@ -1235,6 +1236,24 @@ class PureDoctestTestCase(unittest.TestCase):
except Exception:
except Exception:
pass
pass
try:
from mypy import api as mypy_api
nomypy = False
except ImportError:
nomypy = True
if 'mypy' in self.tags['tag'] and not nomypy:
mypy_result = mypy_api.run((
self.module_path,
'--ignore-missing-imports',
'--follow-imports', 'skip',
))
if mypy_result[2]:
import pdb; pdb.set_trace()
self.fail(mypy_result[0])
is_private_field = re.compile('^_[^_]').match
is_private_field = re.compile('^_[^_]').match
class _FakeClass(object):
class _FakeClass(object):
...
...
test-requirements.txt
View file @
2386a4cb
numpy
numpy
jupyter
jupyter
coverage
coverage
mypy
tests/run/pure_py3.py
View file @
2386a4cb
# mode: run
# mode: run
# tag: annotation_typing, pure3.0
# tag: annotation_typing, pure3.0
, mypy
import
cython
import
cython
...
@@ -7,7 +7,7 @@ is_compiled = cython.compiled
...
@@ -7,7 +7,7 @@ is_compiled = cython.compiled
MyUnion
=
cython
.
union
(
n
=
cython
.
int
,
x
=
cython
.
double
)
MyUnion
=
cython
.
union
(
n
=
cython
.
int
,
x
=
cython
.
double
)
MyStruct
=
cython
.
struct
(
is_integral
=
cython
.
bint
,
data
=
MyUnion
)
MyStruct
=
cython
.
struct
(
is_integral
=
cython
.
bint
,
data
=
MyUnion
)
MyStruct2
=
cython
.
typedef
(
MyStruct
[
2
])
MyStruct2
=
cython
.
typedef
(
MyStruct
[
2
])
# type: cython.StructType
@
cython
.
ccall
# cpdef => C return type
@
cython
.
ccall
# cpdef => C return type
...
...
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