We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have the following function in a compilable .py file
@cython.cclass class TestClass: @staticmethod @cython.cfunc def func(v: cython.double) -> cython.double: return v + 1.0
With a corresponding .pxd file having
cdef class TestClass: @staticmethod cdef double func(double v)
When I try to compile it I get the following error:
(venv311) C:\Users\Juan\cruji-enaire>python setup.py build_ext --inplace Compiling src/crujisim/cythontests.py because it changed. [1/1] Cythonizing src/crujisim/cythontests.py Error compiling Cython file: ------------------------------------------------------------ ... return a @cython.cclass class TestClass: @staticmethod ^ ------------------------------------------------------------ src\crujisim\cythontests.py:515:4: Signature not compatible with previous declaration Error compiling Cython file: ------------------------------------------------------------ ... cdef class TestClass: @staticmethod cdef double func(double v) ^ ------------------------------------------------------------ src\crujisim\cythontests.pxd:4:20: Previous declaration is here Traceback (most recent call last): File "C:\Users\Juan\cruji-enaire\setup.py", line 11, in <module> cythonized = cythonize(["src/crujisim/mathutil.py", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Juan\venv311\Lib\site-packages\Cython\Build\Dependencies.py", line 1129, in cythonize cythonize_one(*args) File "C:\Users\Juan\venv311\Lib\site-packages\Cython\Build\Dependencies.py", line 1296, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: src/crujisim/cythontests.py
Yet, if I rename the file to pyx and rewrite the function as
cdef class TestClass: @staticmethod cdef double func(v: double): return v + 1.0
It does compile properly
I expected the function to compile correctly in pure python, since it is equivalent
OS: Windows Python version [e.g. 3.11] Cython version [e.g. 3.0.0a11]
No response
The text was updated successfully, but these errors were encountered:
I'm also getting a similar thing with another method returning int.
This doesn't work
@cython.cclass class TestClass: @cython.ccall def intfunc(self, v: cython.int) -> cython.int: return v + 1
With the corresponding pxd file
cdef class TestClass: cpdef int intfunc(self, int v)
But this does work with the same .pxd file
cdef class TestClass: cpdef int intfunc(self, int v): return v + 1
Sorry, something went wrong.
This looks like a wrong behavior
No branches or pull requests
Describe the bug
I have the following function in a compilable .py file
With a corresponding .pxd file having
When I try to compile it I get the following error:
Yet, if I rename the file to pyx and rewrite the function as
It does compile properly
Expected behaviour
I expected the function to compile correctly in pure python, since it is equivalent
Environment
OS: Windows
Python version [e.g. 3.11]
Cython version [e.g. 3.0.0a11]
Additional context
No response
The text was updated successfully, but these errors were encountered: