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

Python 3.9 typing and multiple-inheritance #987

Closed
Bleyddyn opened this issue Feb 1, 2022 · 1 comment
Closed

Python 3.9 typing and multiple-inheritance #987

Bleyddyn opened this issue Feb 1, 2022 · 1 comment

Comments

@Bleyddyn
Copy link
Contributor

Bleyddyn commented Feb 1, 2022

Trying to train using Python 3.9:

using donkey v4.3.5 ...
Traceback (most recent call last):
  File "/Users/Shared/Personal/mycar/./train.py", line 17, in <module>
    from donkeycar.pipeline.training import train
  File "/Users/Shared/Personal/donkeycar/donkeycar/pipeline/training.py", line 13, in <module>
    from donkeycar.pipeline.sequence import TubRecord, TubSequence, TfmIterator
  File "/Users/Shared/Personal/donkeycar/donkeycar/pipeline/sequence.py", line 45, in <module>
    class TfmIterator(Generic[R, XOut, YOut],  SizedIterator[Tuple[XOut, YOut]]):
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/abc.py", line 106, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
TypeError: Cannot create a consistent method resolution
order (MRO) for bases Generic, SizedIterator

The solution seems to be to add intermediate classes. e.g.

-class TfmIterator(Generic[R, XOut, YOut],  SizedIterator[Tuple[XOut, YOut]]):
+class IntermediateIterator(Generic[R, XOut, YOut]):
+    def __init__(self) -> None:
+        pass
+
+class TfmIterator(IntermediateIterator[R, XOut, YOut],  SizedIterator[Tuple[XOut, YOut]]):

I haven't tested with older versions of Python, but I was able to get a training run to finish with 3.9.

I'm new to python typing and multiple inheritance, so I don't know if there's a better way to do this.

@DocGarbanzo
Copy link
Contributor

There have been some impact changes in mypy between python 3.7 -> 3.9, which we have to address. Thanks for your comment on how to resolve them. We'll have a look once we'll work on that upgrade.

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

2 participants