File: e_typing_optional.py

package info (click to toggle)
cython 3.1.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,932 kB
  • sloc: python: 92,172; ansic: 19,275; cpp: 1,407; xml: 1,031; javascript: 511; makefile: 373; sh: 223; sed: 11
file content (43 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# mode: error

import cython

try:
    from typing import Optional
except ImportError:
    pass


# not OK

def optional_cython_types(i: Optional[cython.int], d: Optional[cython.double], f: Optional[cython.float],
                          c: Optional[cython.complex], l: Optional[cython.long], ll: Optional[cython.longlong]):
    pass


MyStruct = cython.struct(a=cython.int, b=cython.double)

def optional_cstruct(x: Optional[MyStruct]):
    pass


# OK

def optional_pytypes(i: Optional[int], f: Optional[float], c: Optional[complex], l: Optional[long]):
    pass


def optional_memoryview(d: double[:], o: Optional[double[:]]):
    pass


_ERRORS = """
13:44: typing.Optional[...] cannot be applied to type int
13:69: typing.Optional[...] cannot be applied to type double
13:97: typing.Optional[...] cannot be applied to type float
14:44: typing.Optional[...] cannot be applied to type double complex
14:73: typing.Optional[...] cannot be applied to type long
14:100: typing.Optional[...] cannot be applied to type long long

20:33: typing.Optional[...] cannot be applied to type MyStruct
"""