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

future doesn't support python3 functions annotations #2

Open
matclab opened this issue Oct 14, 2013 · 2 comments
Open

future doesn't support python3 functions annotations #2

matclab opened this issue Oct 14, 2013 · 2 comments

Comments

@matclab
Copy link

matclab commented Oct 14, 2013

I just tried future on a python3 program and it fails on python3 functions annotations (http://www.python.org/dev/peps/pep-3107/) :

    def _parse(self, filename: str, dir='.') -> list:
                             ^
SyntaxError: invalid syntax

I'm not sure if there is a way to fix this.

@edschofield
Copy link
Contributor

Hi @matclab,

Thanks for reporting this. Yes, this is a known limitation. Any Python 3-only syntax will fail to run on Python 2; importing future cannot help with this because Python won't even attempt to run code that generates a SyntaxError.

The futurize script could potentially convert function annotations into the following syntax, which is compatible with both Py2 and Py3 (using your example)::

def _parse(self, filename, dir='.'):
    ...
_parse.__annotations__ = {'filename': str, 'return': list}

Would this meet your use-case? I have filed this as a feature request in issue #3.

@matclab
Copy link
Author

matclab commented Nov 2, 2013

I may give a try, but I can not see why it won't work for my use case…
Thanks for having considered it.

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