Closed domthom21 closed 1 year ago
Describe the bug Currently, multiplication and division of Units return an AbstractUnit or float. However, they should return the specific unit type
To Reproduce
_elastic_modulus: Pascal = 210_000*N()/mm2() $ python -m mypy --config-file mypy.ini -p eurocodedesign eurocodedesign\materials\structuralsteel.py:41: error: Incompatible types in assignment (expression has type "AbstractUnit | float", variable has type "Pascal") [assignment] _elastic_modulus: Pascal = 210_000*N()/mm2()
Expected behavior E.g. 210_000*N()/mm2() should return Pascal specifically
Additional context Fix according to https://docs.python.org/3/library/typing.html#typing.overload Overloading is necessary for __mul__ and __true_div__ in units\__init__.py according to _allowed_multipliucations
__mul__
__true_div__
units\__init__.py
_allowed_multipliucations
Fixed with #74
Describe the bug Currently, multiplication and division of Units return an AbstractUnit or float. However, they should return the specific unit type
To Reproduce
Expected behavior E.g. 210_000*N()/mm2() should return Pascal specifically
Additional context Fix according to https://docs.python.org/3/library/typing.html#typing.overload Overloading is necessary for
__mul__
and__true_div__
inunits\__init__.py
according to_allowed_multipliucations