royerlab / napari-chatgpt

A napari plugin to process and analyse images with chatGPT!
BSD 3-Clause "New" or "Revised" License
233 stars 25 forks source link

Incompatibility with pyside2 (napari bundle), due to outdated black import #54

Open psobolewskiPhD opened 1 month ago

psobolewskiPhD commented 1 month ago

Failed to import command at ‘napari_chatgpt._widget:OmegaQWidget’: cannot import name ‘FileMode’ from ‘black’ Originally posted: forum.image.sc/t/failed-to-import-command-at-napari-chatgpt/99260 The napari conda bundle uses pyside2 as Qt back end. The issue looks like an incompatibility between the specific black import and pyside2 With black, from black import FileMode fails in the bundle or napari env with pyside2 but works with pyqt5. Here's the error:

from black import FileMode
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 from black import FileMode

File ~/Dev/miniforge3/envs/napari-050ps2/lib/python3.9/site-packages/shiboken2/files.dir/shibokensupport/feature.py:139, in _import(name, *args, **kwargs)
    137     default = 0 if name.split(".")[0] == "PySide2" else -1
    138     pyside_feature_dict[importing_module] = default
--> 139 return original_import(name, *args, **kwargs)

File src/black/__init__.py:67

File src/black/linegen.py:73

File src/black/trans.py:251

TypeError: mypyc classes can't have a metaclass

That import looks outdated? see: https://github.com/psf/black/commit/06f2790b5ca3fea45515e33c9660ad6265120a5a

royerloic commented 3 weeks ago

Ok, working on a workaround, making the import of black local, should help. Will post an update here is the bug is confirmed gone.