dbrattli / OSlash

Functors, Applicatives, And Monads in Python
MIT License
708 stars 50 forks source link

TypeError: Cannot create a consistent method resolution order (MRO) for bases Generic, Monad, Applicative, Functor #11

Closed fengwang closed 5 years ago

fengwang commented 5 years ago

When trying to run hello.py under folder examples, something goes wrong with following error message:

» python3 ./hello.py                                                                                                                      feng@DDM05959
Traceback (most recent call last):
  File "./hello.py", line 1, in <module>
    from oslash import put_line, get_line
  File "/usr/lib/python3.7/site-packages/oslash/__init__.py", line 10, in <module>
    from .identity import Identity
  File "/usr/lib/python3.7/site-packages/oslash/identity.py", line 13, in <module>
    class Identity(Generic[A], Monad, Applicative, Functor):
  File "/usr/lib/python3.7/abc.py", line 126, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
TypeError: Cannot create a consistent method resolution
order (MRO) for bases Generic, Monad, Applicative, Functor

Python version

 » python3                                                                                                                                 feng@DDM05959
Python 3.7.0 (default, Jul 15 2018, 10:44:58)
[GCC 8.1.1 20180531] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.version
'3.7.0 (default, Jul 15 2018, 10:44:58) \n[GCC 8.1.1 20180531]'
>>>
dbrattli commented 5 years ago

@fengwang The issue was auto closed because it should now be fixed in commit https://github.com/dbrattli/OSlash/commit/ffdc714c5d454f7519f740254de89f70850929eb . Please re-open if this commit does not fix your problems.

fengwang commented 5 years ago

@dbrattli Sorry, I did not notice ffdc714 before ask you. I have just tried ffdc714, and everything works now. Thanks.

grayfall commented 4 years ago

@dbrattli I am a bit late to the party, but you could have left the Generic. I've run into the same issue whilst testing my personal package for parametric ("higher kind-ish") types on Python 3.7. All you need to do is to make Generic the last superclass (instead of the first one). This change does not break compatibility with Python 3.6.