haosulab / MPlib

a Lightweight Motion Planning Package
https://motion-planning-lib.readthedocs.io/
MIT License
145 stars 22 forks source link

Compatibility Issue with Python 3.9 in mplib v0.2.1 #98

Open chase6305 opened 1 month ago

chase6305 commented 1 month ago

Description:

I encountered a compatibility issue while trying to use mplib 0.2.1 with Python 3.9.19. The following error occurs during the import:

TypeError: unsupported operand type(s) for |: 'type' and 'type'

Error Traceback:

Traceback (most recent call last):  
  File ~/anaconda3/envs/py39/lib/python3.9/site-packages/mplib/__init__.py:3  
    from .planner import Planner  
  File ~/anaconda3/envs/py39/lib/python3.9/site-packages/mplib/planner.py:16  
    from .urdf_utils import generate_srdf, replace_urdf_package_keyword  
  File ~/anaconda3/envs/py39/lib/python3.9/site-packages/mplib/urdf_utils.py:136  
    urdf_path: str | Path,  
TypeError: unsupported operand type(s) for |: 'type' and 'type'  

Expected Behavior:

The library should be compatible with Python 3.9 and should not raise a TypeError when importing.

Proposed Solution:

To ensure compatibility with Python 3.9 and earlier versions, I suggest modifying the type hint in urdf_utils.py:

from typing import Union

Change this line:

urdf_path: str | Path

To:

urdf_path: Union[str, Path]

This change should resolve the issue and allow the library to work correctly in Python 3.9.

Environment:

Thank you!

Lexseal commented 1 month ago

Yes that's a good point! We will fix it : )

Lexseal commented 1 month ago

it should be fixed in the nightly build. accidentally pushed main sorry @KolinGuo lol