summaryrefslogtreecommitdiff
path: root/tests/run/typing_module.py
Commit message (Collapse)AuthorAgeFilesLines
* Implement cdef dataclasses (GH-3400)da-woods2022-01-291-0/+42
New decorator/function "@cython.dataclasses.dataclass" and "cython.dataclasses.field()" to mark dataclasses and their fields. Tries to match the interface provided by a regular dataclass as much as possible. This means taking the types from the dataclasses module if available (so they match exactly) or a fallback Python version that just implements the core parts (executed with "PyRun_String()" in the C source). Use of placeholders in generated "__init__" code means the code in the C file isn't hugely readable. Probably not a huge issue, but don't really see a way round that. As part of this I've also also implemented a Cython version of "typing.ClassVar". Although really designed for use with dataclasses it behaves sensibly when used in types in a normal cdef class. This is worth documenting more thoroughly. Closes https://github.com/cython/cython/issues/2903