Skip to content
Advertisement

Tag: python-3.5

Optional[Type[Foo]] raises TypeError in Python 3.5.2

This code: will raise TypeError on 3.5.2: whereas it runs fine on 3.6. Same problem if I spell out Optional as Union[None, Type[Foo]]. Is there any workaround for 3.5.2, while still accurately annotating the return type? Answer This is a bug in Python 3.5.2. Optional[cls] is a wrapper for Union[cls, type(None)], which uses __subclasses__() to establish whether one class is

Python type hinting without cyclic imports

I’m trying to split my huge class into two; well, basically into the “main” class and a mixin with additional functions, like so: main.py file: mymixin.py file: Now, while this works just fine, the type hint in MyMixin.func2 of course can’t work. I can’t import main.py, because I’d get a cyclic import and without the hint, my editor (PyCharm) can’t

installing cPickle with python 3.5

This might be silly but I am unable to install cPickle with python 3.5 docker image Dockerfile requirements.txt When I try to build the image Answer cPickle comes with the standard library… in python 2.x. You are on python 3.x, so if you want cPickle, you can do this: However, in 3.x, it’s easier just to use pickle. No need

Advertisement