CenterForTheBuiltEnvironment / pythermalcomfort

Package to calculate several thermal comfort indices (e.g. PMV, PPD, SET, adaptive) and convert physical variables.
https://pythermalcomfort.readthedocs.io/en/latest/
MIT License
147 stars 52 forks source link

Type hints prevent importing in python 3.9 #102

Closed szvsw closed 8 months ago

szvsw commented 8 months ago

Describe the bug

The most recent commit (1139fbfbeb0f9a80dcbd8dfc9211e2b22614dffb) triggers errors upon importing in Py3.9 because using boolean syntax for union types was introduced in Python 3.10. Using Union syntax would be preferable, e.g. Union[int,float] instead of int | float. (will need to use from typing import Union)

To Reproduce

from pythermalcomfort import pmv

Yields

Traceback (most recent call last):
  File "<pathtomyfile>.py", line 8, in <module>
    from pythermalcomfort import pmv
  File "<pathtomypackages>\pythermalcomfort\__init__.py", line 3, in <module>
    from pythermalcomfort.models import *
  File "<pathtomypackages>\pythermalcomfort\models\__init__.py", line 9, in <module>
    from pythermalcomfort.models.pmv import pmv
  File "<pathtomypackages>\pythermalcomfort\models\pmv.py", line 9, in <module>
    tdb: Union[float, int, np.ndarray, list[int | float]],
TypeError: unsupported operand type(s) for |: 'type' and 'type'

Expected behavior

Imports are possible on py3.9.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): Windows 10, py3.9

Additional context Add any other context about the problem here.

If py3.9 is not intended to be supported, this could be indicated. As far as I am aware, it is intended to be supported.

FedericoTartarini commented 8 months ago

Thank you so much for reporting this issue, I will try to fix it as soon as possible. I will publish a new version of pythermalcomfort before the end of the week, in the meantime, please install an older version of pythermalcomfort. Sorry for causing this issue.

FedericoTartarini commented 8 months ago

I have fixed the issue and published a new version of pythermalcomfort. The new version 2.10.0 is compatible with Python 3.8, 3.9, 3.10, 3.11