lucidrains/muse-maskgit-pytorch

beartype error: unhashable type: 'list'

forresti opened this issue · 2 comments

I installed the code and its dependencies. When I do from muse_maskgit_pytorch import VQGanVAE, MaskGit, MaskGitTransformer, it fails in muse_maskgit_pytorch when importing beartype:

/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/torch/onnx/_internal/_beartype.py:30: UserWarning: unhashable type: 'list'
  warnings.warn(f"{e}")
Traceback (most recent call last):
  File "/scratch/code/muse-maskgit-pytorch/./fni_main.py", line 3, in <module>
    from muse_maskgit_pytorch import VQGanVAE, MaskGit, MaskGitTransformer
  File "/scratch/code/muse-maskgit-pytorch/muse_maskgit_pytorch/__init__.py", line 2, in <module>
    from muse_maskgit_pytorch.muse_maskgit_pytorch import Transformer, MaskGit, Muse, MaskGitTransformer, TokenCritic
  File "/scratch/code/muse-maskgit-pytorch/muse_maskgit_pytorch/muse_maskgit_pytorch.py", line 16, in <module>
    from beartype import beartype
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/__init__.py", line 57, in <module>
    from beartype._decor.decormain import (
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_decor/decormain.py", line 23, in <module>
    from beartype._conf.confcls import (
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_conf/confcls.py", line 23, in <module>
    from beartype._cave._cavemap import NoneTypeOr
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_cave/_cavemap.py", line 33, in <module>
    from beartype._util.hint.nonpep.utilnonpeptest import (
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_util/hint/nonpep/utilnonpeptest.py", line 21, in <module>
    from beartype._util.cache.utilcachecall import callable_cached
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_util/cache/utilcachecall.py", line 32, in <module>
    from beartype._util.func.arg.utilfuncargtest import (
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_util/func/arg/utilfuncargtest.py", line 17, in <module>
    from beartype._util.func.utilfunccodeobj import get_func_codeobj
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_util/func/utilfunccodeobj.py", line 21, in <module>
    from beartype._data.datatyping import (
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/site-packages/beartype/_data/datatyping.py", line 129, in <module>
    BeartypeReturn = Union[BeartypeableT, BeartypeConfedDecorator]
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/typing.py", line 243, in inner
    return func(*args, **kwds)
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/typing.py", line 316, in __getitem__
    return self._getitem(self, parameters)
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/typing.py", line 421, in Union
    parameters = _remove_dups_flatten(parameters)
  File "/home/forrest/anaconda3/envs/mar2023_maskgit/lib/python3.9/typing.py", line 215, in _remove_dups_flatten
    all_params = set(params)
TypeError: unhashable type: 'list'

I googled "beartype unhashable type import error," but I haven't yet been able to find anything about this error. Does anyone else hit this problem?

  • I'm using Python 3.9. Is that an ok version to use?
  • I am using beartype 0.12.0, which is what was automatically installed when I installed the muse-maskgit-pytorch code.

@forresti are you using python 3.9.1 by any chance? beartype/beartype#99

...heh. The classic TypeError: unhashable type: 'list' exception, huh? Yeah. This isn't actually @beartype's fault. This is CPython's fault. Specifically, this is a bug in older implementations of the standard typing module under CPython < 3.9.2.

As @lucidrains suggests, you're almost certainly running an ancient version of CPython 3.9 (e.g., 3.9.0, 3.9.1). You desperately want to upgrade CPython. Of course, you desperately want to upgrade CPython anyway. Obsolete versions of anything are security risks that increase attack surface. Doubly so if the security risk in question is CPython itself. I grimace. 😬