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

Data type annotation #103

Open
smmaurer opened this issue Mar 6, 2019 · 0 comments
Open

Data type annotation #103

smmaurer opened this issue Mar 6, 2019 · 0 comments

Comments

@smmaurer
Copy link
Member

smmaurer commented Mar 6, 2019

Recent versions of Python have been building out support for data type annotation, where you can indicate the expected types of function inputs and outputs, or of standalone variables.

The annotations don't affect anything at runtime, but they allow static checks for consistency during development and testing, and some other cool things. Types can be simple (int, bool), compound (e.g. lists or dicts of other things), or classes.

It would be great to include type annotation throughout UrbanSim Templates! Not only does it seem like a good coding practice for library building, but it also aligns well with what the templates themselves are trying to accomplish.

The annotation syntax is compatible with Python 3.0+, but most of the useful features were introduced in Python 3.6. In Python 2.7 the annotations will raise a SyntaxError, so we'd have to drop Python 2.7 support if we add this. I think it would probably be worth it.

Resources:

Additional functionality coming in Python 3.8: https://www.python.org/dev/peps/pep-0557/

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