jszopi / repESP

Reproducing molecular ESP from partial charges and more
GNU General Public License v3.0
6 stars 7 forks source link

Offer runtime type checking #48

Open jszopi opened 5 years ago

jszopi commented 5 years ago

An Any type can easily slip into library functions, whether due to user or library code. As conjectured in Issue #44, a single Any can allow silent but serious library misuse, only to be discovered at runtime (if at all). Further, I can't expect all users to type-annotate their code and run mypy --strict, leaving even more room for incorrect types being passed in to the library.

Runtime type checking based on PEP 484 annotations is possible. I hope there will be no code changes required. The checks will add runtime overhead, so it must be possible for the users to switch them off. Once this is implemented, the documentation on static type checking should be simplified or even largely removed for the benefit of unfamiliar users. The checks should always be on for unit tests.

The only library I'm aware of is pydantic, but I have yet to research alternatives.