evereux / pycatia

python module for CATIA V5 automation
MIT License
204 stars 53 forks source link

[BUG] Import error with python <= 3.9 #194

Closed champystile closed 8 months ago

champystile commented 9 months ago

Describe the bug When importing pycatia with python 3.9, it raises a TypeError due to an annotation syntax introduced in python 3.10 :

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\...\lib\site-packages\pycatia\__init__.py", line 21, in <module>
    from pycatia.base_interfaces.base_application import catia_application as catia
  File "C:\...\lib\site-packages\pycatia\base_interfaces\base_application.py", line 5, in <module>
    from pycatia.in_interfaces.application import Application
  File "C:\...\lib\site-packages\pycatia\in_interfaces\application.py", line 10, in <module>
    from pycatia.in_interfaces.document import Document
  File "C:\...\lib\site-packages\pycatia\in_interfaces\document.py", line 17, in <module>
    from pycatia.in_interfaces.cameras import Cameras
  File "C:\...\lib\site-packages\pycatia\in_interfaces\cameras.py", line 13, in <module>
    from pycatia.in_interfaces.camera import Camera
  File "C:\...\lib\site-packages\pycatia\in_interfaces\camera.py", line 12, in <module>
    from pycatia.system_interfaces.any_object import AnyObject
  File "C:\...\lib\site-packages\pycatia\system_interfaces\any_object.py", line 13, in <module>
    from pycatia.base_interfaces.pycatia import PyCATIA
  File "C:\...\lib\site-packages\pycatia\base_interfaces\pycatia.py", line 5, in <module>
    from pycatia.cat_logger import create_logger
  File "C:\...\lib\site-packages\pycatia\cat_logger.py", line 9, in <module>
    def has_level_handler(logger: logging.Logger | None):
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

To Reproduce With python 3.9 and pycatia 0.6.6, import pycatia :

import pycatia

Expected behavior No exception :)

Desktop (please complete the following information):

Additional context Known solution: replace logging.Logger | None by Optional[logging.Logger] in the file cat_logger.py, line 9

evereux commented 8 months ago

Thanks for reporting this. I'll try and get this done this week.

evereux commented 8 months ago

Closing as 0.6.7 now has these changes implemented.