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: NamedTuple doesn't work after cythonization #2649

Closed
verailina opened this issue Oct 9, 2018 · 2 comments
Closed

Bug: NamedTuple doesn't work after cythonization #2649

verailina opened this issue Oct 9, 2018 · 2 comments

Comments

@verailina
Copy link

verailina commented Oct 9, 2018

I have some module defining a NamedTuple:

nmt.py:

from typing import NamedTuple

class Employee(NamedTuple):
    name: str
    id: int

and a simple setup.py:

from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules=cythonize("nmt.py"))

I build the module like this

python setup.py build_ext --inplace

The result class Employee can't be properly instantiated:

>>> from nmt import Employee

>>> Employee("a", 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __new__() takes 1 positional argument but 3 were given

>>> Employee("a")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __new__() takes 1 positional argument but 2 were given

>>> Employee()
Employee()
@scoder
Copy link
Contributor

scoder commented Oct 14, 2018

Duplicate of #2552.

@scoder scoder closed this as completed Oct 14, 2018
@beruhan
Copy link

beruhan commented Apr 10, 2019

does any one has alternative plan? this usage is heavily used in the project.,and I don't know how to

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

No branches or pull requests

3 participants