erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.8k stars 743 forks source link

Interest in stronger Python typing? #203

Closed jspahrsummers closed 4 years ago

jspahrsummers commented 4 years ago

I'm interested in adding more comprehensive typing support to ib_insync (since it's hard to automate any kind of testing around TWS, static typing can at least catch some mistakes).

More than happy to do this and contribute back, but since the pull request could get quite large, wanted to ask a couple of questions ahead of time:

  1. Does this sound valuable?
  2. Not strictly necessary, but are you open to using dataclasses from Python 3.7? This would increase the minimum version requirement of ib_insync from 3.6, but it could take care of a lot of the type introspection behaviors (e.g., those implemented in Object right now).
erdewit commented 4 years ago

Hello Justin, yes I'm interested in more type annotations. Mostly for the publicly exposed parts, to help with type hinting for editors.

I have thought about using dataclasses when they came out with Python 3.7, but at that time compatibility with Python 3.6 was important. Nowadays there is a dataclasses backport to Python 3.6 and I think it's a good idea to start using them. Apart from better testibility it will give type hinting and code completion which is currently lacking for Object fields. There are some tricky parts for implementing them in ib_insync (with order serialization etc) but I have some time now and will start on it.

erdewit commented 4 years ago

Just to let you know, these typing hints and dataclasses are now released in v0.9.59. Thanks again!

jspahrsummers commented 4 years ago

Awesome, thank you!