File: pure_warnings.py

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (73 lines) | stat: -rw-r--r-- 2,105 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# mode: error
# tag: warnings

import cython
import typing
from cython.cimports.libc import stdint


def main():
    foo1: typing.Tuple = None
    foo1: typing.Bar = None
    foo2: Bar = 1  # warning
    foo3: int = 1
    foo4: cython.int = 1
    foo5: stdint.bar = 5  # warning
    foo6: object = 1
    foo7: cython.bar = 1  # error
    foo8: (1 + x).b
    foo9: mod.a.b
    foo10: func().b
    foo11: Bar[:, :, :]  # warning
    foo12: cython.int[:, ::1]
    with cython.annotation_typing(False):
        foo8: Bar = 1
        foo9: stdint.bar = 5
        foo10: cython.bar = 1


@cython.cfunc
def bar() -> cython.bar:  # error
    pass


@cython.cfunc
def bar2() -> Bar:  # warning
    pass

@cython.cfunc
def bar3() -> stdint.bar:  # error
    pass

def bar4(a: cython.foo[:]):  # error
    pass

_WARNINGS = """
12:10: Unknown type declaration 'Bar' in annotation, ignoring
15:16: Unknown type declaration 'stdint.bar' in annotation, ignoring
18:17: Unknown type declaration in annotation, ignoring
19:15: Unknown type declaration in annotation, ignoring
20:17: Unknown type declaration in annotation, ignoring
21:14: Unknown type declaration in annotation, ignoring
35:14: Unknown type declaration 'Bar' in annotation, ignoring
39:20: Unknown type declaration 'stdint.bar' in annotation, ignoring

# Spurious warnings from utility code - not part of the core test
25:10: 'cpdef_method' redeclared
36:10: 'cpdef_cname_method' redeclared
961:29: Ambiguous exception value, same as default return value: 0
961:29: Ambiguous exception value, same as default return value: 0
1002:46: Ambiguous exception value, same as default return value: 0
1002:46: Ambiguous exception value, same as default return value: 0
1092:29: Ambiguous exception value, same as default return value: 0
1092:29: Ambiguous exception value, same as default return value: 0
"""

_ERRORS = """
17:16: Unknown type declaration 'cython.bar' in annotation
30:13: Not a type
30:19: Unknown type declaration 'cython.bar' in annotation
35:14: Not a type
39:14: Not a type
42:18: Unknown type declaration 'cython.foo[:]' in annotation
"""