Skip to content
New issue

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

[BUG] ctuple declaration on inherited membed function when parent class imported .pxd yields "Signature not compatible with previous declaration" error #6231

Open
raffienficiaud opened this issue Jun 7, 2024 · 0 comments

Comments

@raffienficiaud
Copy link
Contributor

raffienficiaud commented Jun 7, 2024

Describe the bug

When we declare a class that derives from another class, and some member functions are inherited, the return type of the inherited member does not accept a declaration as a ctuple. In that case cythonize returns an error indicating

Signature not compatible with previous declaration

It works perfectly with simpler types that do not have a parenthesis (such as tuple, double...) and it also works when the parent and child class are within the same .pyx file.

Code to reproduce the behaviour:

The following does not work
parent.pxd

# cython: language_level=3

cdef class Parent:
    cpdef (double, double) func(self, double[:] a, double[:] b)

and child.pyx

# cython: language_level=3

from parent cimport Parent

cdef class Child(Parent):
    cpdef (double, double) func(self, double[:] a, double[:] b):
        return 0,1

The following works:

parent.pxd

# cython: language_level=3

cdef class Parent:
    cpdef tuple func(self, double[:] a, double[:] b)

and child.pyx

# cython: language_level=3
from parent cimport Parent

cdef class Child(Parent):
    cpdef tuple func(self, double[:] a, double[:] b):
        return 0,1

The following works:

child.pxd # note here this is "child.pxd" and not "parent.pxd"

# cython: language_level=3

cdef class Parent:
    cpdef (double, double) func(self, double[:] a, double[:] b)

and child.pyx

# cython: language_level=3

cdef class Parent:
    cpdef (double, double) func(self, double[:] a, double[:] b):
        pass


cdef class Child(Parent):
    cpdef (double, double) func(self, double[:] a, double[:] b):
        return 0,1

Expected behaviour

The return type of the inherited member function can always be ctuple even if/when we are spanning several cython modules.

OS

No response

Python version

3.11

Cython version

3.0.10

Additional context

The command for running is simply cythonize child.pyx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant