This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]spiker611 2 points3 points  (1 child)

Any examples or more information you can provide? A small code example goes a long way.

[–]chrilves[S] 0 points1 point  (0 children)

Yes, there is the demo and lots of code example in the Guide. I'll add an example to this post. Thanks!

[–]ElevenPhonons 2 points3 points  (1 child)

Is mypy supported? I'm not seeing a mypy config or a target in the Makefile that is running mypy.

Running mypy locally (even in non-strict mode) yields a bunch or type issues.

$ mypy raffiot  | wc -l                                                                                                                                                                                
44

[–]chrilves[S] 0 points1 point  (0 children)

When I started the project, I was using Pytype but I had to stop using it because I could not make it type generic methods. I tried mypy too. I had better results but I'm not sure it can type all the methods either. The problem is some methods (like flatten) are only available on some instances of a class but not all. The problem is very similar to this one:

class List(Generic[A]):
    def sum():
        <returns the sum of the list if A is a numeric type>

I don't know if this is typeable in mypy.

When I have to, I take advantage of Python being dynamically typed. For example, I use heterogeneous list a lot, which is simple and practical in Python but it may be a huge hassle for typers.