-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
I'm trying to have some type safety which involves having a variable known to be a type of ConfigurationSpace, however mypy fails completely at this and downcasts it to simply be Any.
My guess is that mypy relies on reading the source files of a library to infer types and does not read .pyx files.
Two possible solutions if we want to support this, while keeping Cython code:
- We move all
.pyxfunctionality to standalone functions and just call them from plain python functions. My estimate from looking at call traces and generated code from previous work is that this interplay between python calling a Cythonized function is relatively low, especially if the types passed beetween the two layers are simple/array types. However this overhead could be quite high if done constantly, which should be avoided. - Release
.pyifiles, essentially typestubs. This would however add even more maintanence issues as these.pyifiles would need to be kept in sync and be correct as they become the source of truth for code linters and mypy, disregarding implementation of the.pyxfiles. There exists non-perfect automated solutions for regular.pyfiles (e.g. pyright can generate them) but a quick google found nothing for cython code.
Metadata
Metadata
Assignees
Labels
No labels

