Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NamedTuple Error with python 3.9.5 #61

Closed
CyrilLeMat opened this issue Jun 22, 2021 · 8 comments
Closed

NamedTuple Error with python 3.9.5 #61

CyrilLeMat opened this issue Jun 22, 2021 · 8 comments

Comments

@CyrilLeMat
Copy link
Collaborator

I had this error running pytest in python 3.9.5

  File "/Users/clemat/.pyenv/versions/3.9.5/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "/Users/clemat/.pyenv/versions/3.9.5/envs/modelkit/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line 170, in exec_module
    exec(co, module.__dict__)
  File "/Users/clemat/dev/modelkit/tests/assets/conftest.py", line 18, in <module>
    from modelkit.assets.manager import AssetsManager
  File "/Users/clemat/dev/modelkit/modelkit/__init__.py", line 3, in <module>
    from modelkit.core.library import ModelLibrary, load_model  # NOQA
  File "/Users/clemat/dev/modelkit/modelkit/core/__init__.py", line 1, in <module>
    from modelkit.core.library import ModelLibrary, load_model
  File "/Users/clemat/dev/modelkit/modelkit/core/library.py", line 35, in <module>
    from modelkit.core.model import Asset, AsyncModel, Model
  File "/Users/clemat/dev/modelkit/modelkit/core/model.py", line 31, in <module>
    from modelkit.utils.cache import Cache, CacheItem
  File "/Users/clemat/dev/modelkit/modelkit/utils/cache.py", line 15, in <module>
    class CacheItem(NamedTuple, Generic[ItemType]):
  File "/Users/clemat/.pyenv/versions/3.9.5/lib/python3.9/typing.py", line 1881, in _namedtuple_mro_entries
    raise TypeError("Multiple inheritance with NamedTuple is not supported")
TypeError: Multiple inheritance with NamedTuple is not supported
======================================================================================= short test summary info ========================================================================================
ERROR  - TypeError: Multiple inheritance with NamedTuple is not supported
@CyrilLeMat CyrilLeMat changed the title with python 3.9.5 NamedTuple Error with python 3.9.5 Jun 22, 2021
@CyrilLeMat
Copy link
Collaborator Author

From what I see, this seems to be an update of NamesTuple in python 3.9
https://bugs.python.org/issue43923
https://bugs.python.org/issue40185

JustAnotherArchivist/snscrape#111
Carsten-Leue/ReduxPY#2

@CyrilLeMat
Copy link
Collaborator Author

HTe simplest seems to rewrite the CacheItem class without NamedTuple

@victorbenichoux
Copy link
Collaborator

HTe simplest seems to rewrite the CacheItem class without NamedTuple

Indeed, it looks like we should use a dataclass instead. The goal with the NamedTuple was to get really fast instantiation of these items. I will work on a PR to fix this later today.

@CyrilLeMat
Copy link
Collaborator Author

I just did this
image

@CyrilLeMat
Copy link
Collaborator Author

it works but we loose the item typing

@victorbenichoux
Copy link
Collaborator

Of course, but do not want to lose typing 😄

@CyrilLeMat
Copy link
Collaborator Author

Here is PR to fix this issue #62

@pquentin
Copy link
Contributor

Closed in #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants