File: dataclass_e1.pyx

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 (22 lines) | stat: -rw-r--r-- 806 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
# mode: error
# tag: warnings
cimport cython

@cython.dataclasses.dataclass(1, shouldnt_be_here=True, init=5, unsafe_hash=True)
cdef class C:
    a: list = []  # mutable
    b: int = cython.dataclasses.field(default=5, default_factory=int)
    c: int

    def __hash__(self):
        pass

_ERRORS = """
6:5: Arguments passed to cython.dataclasses.dataclass must be True or False
6:5: Cannot overwrite attribute __hash__ in class C
6:5: cython.dataclasses.dataclass() got an unexpected keyword argument 'shouldnt_be_here'
6:5: cython.dataclasses.dataclass takes no positional arguments
7:14: mutable default <class 'list'> for field a is not allowed: use default_factory
8:37: cannot specify both default and default_factory
9:4: non-default argument 'c' follows default argument in dataclass __init__
"""