Skip to content

Investigate the use of type hints #457

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

Closed
drvinceknight opened this issue Jan 5, 2016 · 10 comments
Closed

Investigate the use of type hints #457

drvinceknight opened this issue Jan 5, 2016 · 10 comments

Comments

@drvinceknight
Copy link
Member

See discussion on #454.

@marcharper
Copy link
Member

It's Python 3 only, there are third party libraries like mypy that have some degree of Python 2 support (with a preprocessor that strips the type annotations I believe).

@marcharper
Copy link
Member

Closing, we can reopen in the future if we drop python 2 support.

@marcharper
Copy link
Member

In Python 3.6 there will supposedly be a way to do this in comments that is compatible with Python 2.7 and 3.6. So we could do this if we drop support for 3.x for x < 6 once 3.6 is released.

Alternatively we could drop support for Python 2.7 and "do it the right way". That's my preference. With the popularity of anaconda I'm skeptical that there is a real need to continue supporting Python 2. We could also get rid of the warnings in #476.

@marcharper marcharper reopened this May 21, 2016
@drvinceknight
Copy link
Member Author

In Python 3.6 there will supposedly be a way to do this in comments that is compatible with Python 2.7 and 3.6. So we could do this if we drop support for 3.x for x < 6 once 3.6 is released.

Perhaps we could wait for 3.7 so we still have the last two 3s?

What advantages do type hints give us? (I don't know what they are. If an explanation is too complicated I'll look it up :) Just being lazy.) I understand that it's about performance, would we need to go back and annotate a bunch of code?

Alternatively we could drop support for Python 2.7 and "do it the right way". That's my preference. With the popularity of anaconda I'm skeptical that there is a real need to continue supporting Python 2. We could also get rid of the warnings in #476.

I think it's still too early to drop py2...

Slightly related: https://python3statement.github.io/ Could be nice to include us on there?

@marcharper
Copy link
Member

Type hints just indicate what the types of variables are for function arguments and return variables, and they can be explicit, like int or more vague, such as sequence. They actually don't do anything now other than providing a way to test the types, but they can (arguably) increase readability. It's possible that the interpreter could take advantage of the type hints eventually but right now I don't believe that cpython does anything other than parse the hints and make them available through the typing module.

@drvinceknight
Copy link
Member Author

Cool, so we wouldn't have to go back and annotate but we could?

@marcharper
Copy link
Member

Exactly.

@meatballs
Copy link
Member

We could use the annotations instead of numpy style docstrings. There's a sphinx extension that will render the docs from them.

@meatballs
Copy link
Member

@marcharper
Copy link
Member

Closing re: #808

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