danielfm / pybreaker

Python implementation of the Circuit Breaker pattern.
BSD 3-Clause "New" or "Revised" License
508 stars 74 forks source link

Fully type annotate `pybreaker.py` #73

Closed Kludex closed 2 years ago

Kludex commented 2 years ago

Fully type annotate pybreaker and enforce it with mypy 😎 👍

I've added comments on things that are not trivial or fully known stuff. Hope it helps, but if you miss something, I don't mind explaining :)

Kludex commented 2 years ago

Also, would you mind publishing a release after this? 🙏

danielfm commented 2 years ago

Would these changes somehow break client code (code that uses pybreaker) that don't use type annotations? Since I'm not familiar with those, I thought I'd better ask. 😅

Kludex commented 2 years ago

Would these changes somehow break client code (code that uses pybreaker) that don't use type annotations? Since I'm not familiar with those, I thought I'd better ask. 😅

No, it doesn't break client code.

Also, the only thing that I changed that is not type related on this PR is the "calling parent constructor" way, which is redundant on Python 3.x. In other words, it's not even a breaking change for pybreaker iteself.

danielfm commented 2 years ago

Not sure I quite like the way Python evolved as a language, these type annotations make the code a lot noiser for my taste, but well, since this is where Python is going, we shall follow. 😄

Thanks for your time, your contributions were greatly appreciated!

Kludex commented 2 years ago

I cannot work without autocompletion, and this PR enables that. 🙏

Also, the type checker helps us to find issues along the way (in this case there were none 🤷‍♂️ ).

Thanks for accepting those PRs! :)