Live data from Hacker News

Show HN: A Python Language Server, Mypy-compatible

zubanls.com

11–15 of 15 posts

Re: Show HN: A Python Language Server, Mypy-compatible

#11
post #4
post #3

Earlier quoted context omitted.

Last time I tried ty and pyre they weren't particularly great with a Django codebase, I'm sure ty will get there at some point, but if this handles django-stubs without any extra faffing, that's one potential selling point. I did have the same thought as you at first though, and only carried on reading when I spotted that it was from the author of Jedi.

Both ty and Pyre are in development, so maybe the answer is just "this works and they don't". But they do promise to work eventually, like end of year if I recall correctly. I don't know what makes Django special in this regard though - is it the ORM models that don't work well with the typing spec or..?

I'm still thinking about a good model for the future, because I know that in the future they will be fine type checkers. I think the biggest advantage I have is that I don't burn big sums of money while doing it, so I only need a modest income. I think my current proposal would be a very fair way to make money. But I also see that this might not work if the competition offers everything for free and open source.

The ORM models do not work with typing at all, you basically have to make a lot of magic work if you want to support it in a type checker (especially if you want to work with reverse foreign keys). Generally type checkers do not just support the Django ORM. For Mypy there's a plugin that works pretty well, but uses runtime information, which further slows down Mypy.

Re: Show HN: A Python Language Server, Mypy-compatible

#12
post #8

Any reason to use and pay for this instead of pyrefly and ty? (Relative maturity wouldn't be a good enough reason as those projects will progress quickly enough and both have great, solid, well backed teams behind them)

I think you underestimate how hard it is to move from Mypy to Pyright in big codebases. Having something very very close to Mypy should be very interesting for some companies with 1mLoC+. Relative maturity can still be a reason for 1-2 years and I have no idea what to do at that point.

Relative maturity can be a reason for quite a while (people overestimate how far Pyrefly and Ty are).

Re: Show HN: A Python Language Server, Mypy-compatible

#13
post #4
post #3

Earlier quoted context omitted.

Last time I tried ty and pyre they weren't particularly great with a Django codebase, I'm sure ty will get there at some point, but if this handles django-stubs without any extra faffing, that's one potential selling point. I did have the same thought as you at first though, and only carried on reading when I spotted that it was from the author of Jedi.

Both ty and Pyre are in development, so maybe the answer is just "this works and they don't". But they do promise to work eventually, like end of year if I recall correctly. I don't know what makes Django special in this regard though - is it the ORM models that don't work well with the typing spec or..?

it's that django does metaprogramming that cannot be expressed in terms of python's static type annotations. you need dedicated plugins that essentially replicate that metaprogramming to generate the relevant types.

it's not just django btw, pretty much any metaprogramming library needs that sort of custom support, including dataclasses - take a look at any python type checker and you will find code specifically replicating what dataclasses does in terms of code generation. for pytype we actually put dataclass and namedtuple support alongside our other third-party plugins in the codebase.

Re: Show HN: A Python Language Server, Mypy-compatible

#15
post #14

nice work! what level of type inference do you do on unannotated code?

Currently none, but I'm currently re-implementing the Jedi part (auto-completions/goto), which needs lots of type inference on unannotated code. There will therefore be soon be a non-compatible mode that infers unannotated code as good as possible. I hope it is going to be ready a month from now.
Post reply on HN