kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.35k stars 995 forks source link

Regression for Python 3.9 due to type hints #1386

Closed rockstorm101 closed 9 months ago

rockstorm101 commented 9 months ago

https://github.com/kliment/Printrun/blame/9a759a03e6893991876a6fe5549b3ac8498e72ae/printrun/gui/widgets.py#L308 introduced in commit https://github.com/kliment/Printrun/commit/4e3d90ad948af94f4a892964eedc566f884412dc produces the following error on a machine running Python 3.9.2. (I'll see if we can automate detecting this kind of errors)

$ ./pronterface.py
Traceback (most recent call last):
  File "/home/rock/Printrun/./pronterface.py", line 30, in <module>
    from printrun.pronterface import PronterApp
  File "/home/rock/Printrun/printrun/pronterface.py", line 32, in <module>
    from . import pronsole
  File "/home/rock/Printrun/printrun/pronsole.py", line 41, in <module>
    from .settings import Settings, BuildDimensionsSetting
  File "/home/rock/Printrun/printrun/settings.py", line 26, in <module>
    from .gui.widgets import get_space
  File "/home/rock/Printrun/printrun/gui/__init__.py", line 29, in <module>
    from .controls import ControlsSizer, add_extra_controls
  File "/home/rock/Printrun/printrun/gui/controls.py", line 21, in <module>
    from .widgets import TempGauge
  File "/home/rock/Printrun/printrun/gui/widgets.py", line 159, in <module>
    class FindAndReplace():
  File "/home/rock/Printrun/printrun/gui/widgets.py", line 308, in FindAndReplace
    def bools_to_flags(self, bools: tuple | list) -> int:
TypeError: unsupported operand type(s) for |: 'type' and 'type'

I haven't looked much onto it but the quick and dirty change below seems to do the trick. Any better ideas @neofelis2X?


- def bools_to_flags(self, bools: tuple | list) -> int:
+ def bools_to_flags(self, bools) -> int:
neofelis2X commented 9 months ago

Oh damn, I was blissfully unaware that this | is only supported 3.10+. Yes I think a simple and pragmatic fix like this is good.

I will set up an older python version to test too.