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

better type system based on py3 type hints #3

Open
asmodehn opened this issue Mar 10, 2017 · 5 comments
Open

better type system based on py3 type hints #3

asmodehn opened this issue Mar 10, 2017 · 5 comments

Comments

@asmodehn
Copy link
Member

We should take inspiration from python3 type hints and https://www.python.org/dev/peps/pep-0483/

It would make things more solid, and would also provide simple python3 compatibility.

The type checker would operate at runtime, with the types providing a "contract" regarding the message structure and content.

Later we might want to extend it to provide contracts for complex node behaviors...

@asmodehn
Copy link
Member Author

typing is supported for python 2.7 and mypy can be used for checking types (could be integrated with catkin_pip)

@asmodehn
Copy link
Member Author

Note there is two distinct topics here :

  • improve our typechecker by matching types / structures / API from types hints PEP, hypothesis, etc.
  • add type hints to our implementation, so that, if people use mypy, they will detect type problems when using messages... but this is just a "nice to have" and not the core functionality. We still need to implement a dynamic type checking, so that we can extend it later to check for concurrency problems...

@asmodehn
Copy link
Member Author

Another (complementary ?) option : https://andreacensi.github.io/contracts/

@asmodehn
Copy link
Member Author

pycontracts seems to be lacking quite a few features, especially when comparing with hypothesis...
We have currently implemented a very basic functional type checker, following hypothesis strategies, not sure if the effort in improving pycontracts is worth it.

Not sure what should be done here to improve/solidify this... maybe generating a type checker for python from a more rigorously typed language like idris ?

Anyway it seems to be quite distinct from defining messages for pyros : We want to give python a nice type system that can :

  • currently support py3 type hints
  • be extended later to support more dynamic contracts (like TLA+ : specifying a state machine for the type - we want to use it like contracts work in erlang, upon message reception to guarantee perceived state from another node )

This will help overall stability for our distributed system.

asmodehn pushed a commit that referenced this issue Apr 24, 2017
@asmodehn
Copy link
Member Author

Python3 is now in progress in #14
However we are not doing anything with python3 types yet.

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

1 participant