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

Cythonized class lacks type annotations #2913

Closed
athre0z opened this issue Apr 4, 2019 · 1 comment
Closed

Cythonized class lacks type annotations #2913

athre0z opened this issue Apr 4, 2019 · 1 comment

Comments

@athre0z
Copy link

athre0z commented Apr 4, 2019

from typing import get_type_hints

class Kitteh:
    attr: float = 123.

print(get_type_hints(Kitteh))

This pure Python code results in different outputs depending on whether it has been cythonized or not.

# Cythonized
$ python -mtestx
{}

# Pure
$ rm testx/*.c testx/*.so
$ python -mtestx
{'attr': <class 'float'>}

This is unfortunate for use cases where you e.g. want to perform data parsing into classes based on type hints. Is this intended behavior? I observed this with both 0.29.6 and the latest master.

I attached a small pipenv project that reproduces the issue.

cythonbug.tar.gz

@scoder
Copy link
Contributor

scoder commented Apr 4, 2019

Duplicate of #2552.

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

2 participants