CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
594 stars 114 forks source link

Improved typing of method signatures for critical paras etc. #142

Closed cloasdata closed 9 months ago

cloasdata commented 9 months ago

Hello Caleb,

our linter/typechecker is flagging some signatures from eos mixtures. Ive updated the the docstring with the correct type.

Any plans to gradefully support python type hints?

Cheers Simon

CalebBell commented 9 months ago

Hello Simon, Thank you for these fixes. I appreciate it. Copy/paste is a terrible thing sometimes, or I would have noticed it.

I have only experimented with using MonkeyType to automatically generate type hint .pyi files in fluids & ht: https://github.com/Instagram/MonkeyType/commits/main In general I greatly enjoy strongly typed languages because types are enforced in them and this allows the compiler to write efficient code, but I have struggled to see the benefit to a project like Thermo in using the type of typing Python offers currently. I am experienced enough to pre-date type hints in Python, and look forward to seeing how they evolve. What is your experience?

Sincerely, Caleb

cloasdata commented 9 months ago

So far most of the typing problems are solved in python but still typing seems to be the area of python with the largest movements. And there are still some pitfalls and some stuff is not very explicit for example when try to use generics. Often taking hours to solve without one productive line of code (which always was a major argument for python).

However, dynamic typing resp. the type checker provide a profound way to avoid type errors before import time. This reduces runtime errors based on type problems significantly. Additional typing then is a lot more convent instead of always maintain the types inside docstring or other constructs. At the end it also forces programmers to have good design and architecture instead of leaving everything to the dynamics of python. So at the end it is like python ducktyping a double edged sword but still with possibility to let the programmer deiced which one needs to be sharper.