diff options
Diffstat (limited to 'tests/errors/dataclass_e1.pyx')
-rw-r--r-- | tests/errors/dataclass_e1.pyx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/errors/dataclass_e1.pyx b/tests/errors/dataclass_e1.pyx new file mode 100644 index 000000000..95d67ad7d --- /dev/null +++ b/tests/errors/dataclass_e1.pyx @@ -0,0 +1,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__ +""" |