Closed jdebacker closed 3 years ago
@jdebacker this just defines a few types to help document function signatures.
For example, the TaxcalcReform
and ParamToolsAdjustment
are used here:
Side note: is_paramtools_format
is now implemented in Tax-Calculator: https://taxcalc.pslmodels.org/api/parameters.html#taxcalc.parameters.is_paramtools_format
@hdoupe Thanks for the reply. I haven't used type hinting or see it before. Just read this Real Python article and not clear on benefits if you already have docstrings noting the types for the inputs and output of functions. Can help catch additional errors?
@jdebacker These type hints from the typing
module are mostly used for type-checking during development in IDEs. However, if you use a static type-checker like mypy
you can find errors based on type hints. Also, I think you can use the typing
module with the built-in isinstance()
function to check for type errors at runtime.
@hdoupe Does this sound correct?
IDEs can also automatically populate the docstring types based on type hints.
Got it - thanks for all the input on the use of the typing
package and how type hints can be useful.
@andersonfrailey I can't quite figure out what the purpose of the
typing.py
module is. Can you help me understand?