Live data from Hacker News

Mypy 1.6

mypy-lang.blogspot.com

91–100 of 114 posts

Re: Mypy 1.6

#91

Has anyone had to choose between Mypy and Pyright? Which is "better"? A couple years ago I was in charge of choosing between the two, and I somewhat flippantly chose Pyright because it felt a lot faster ( Later, I realized that some popular libraries we use (django, numpy) have dedicated plugins for Mypy that you can't use with Pyright. So you have to look for Pyright-friendly type stubs or roll your own. I've genera…

Last I tried it, pyright had several false positives that didn't affect mypy. So I remained with mypy.

Re: Mypy 1.6

#92

Is anyone still using mypy, and if so why? I have replaced it by pyright [0] for a while now, and not looking back. It’s been a faster, more powerful replacement with (in my case), zero downside. [0]: https://github.com/microsoft/pyright

    apt install pyright
    E: Unable to locate package pyright

    apt install mypy
    mypy is already the newest version (1.6.0-1).

Re: Mypy 1.6

#93

Is anyone still using mypy, and if so why? I have replaced it by pyright [0] for a while now, and not looking back. It’s been a faster, more powerful replacement with (in my case), zero downside. [0]: https://github.com/microsoft/pyright

I had started using mypy a couple years ago and simply never looked back at the decision. I perceived pyright as a Microsoft-specific tool, and waved it off, as mypy seemed the blessed and eventually converged-upon target. Turns out that’s wrong so far. Tons of people advocating for the latter. I quickly looked at the two repos. Pyright has 30 open issues. Mypy is at 2200. That is a simplistic metric, but an immense…

I guess mypy has 10x more users as well. People who use pyright use an IDE and they aren't likely to report a bug.

https://pypistats.org/packages/mypy

https://pypistats.org/packages/pyright

Re: Mypy 1.6

#94

Earlier quoted context omitted.

readability of the code to other developers I disagree that Go's insistence on verbosity improves readability. Each individual line may simpler, but the larger purpose of the code is obscured in all the "if err != nil" weeds. My unpopular opinion is that Dart should get a lot more attention. Strong typing with null-safety, compiles to native, batteries included, and nearly as expressive as Python.

> but the larger purpose of the code is obscured in all the "if err != nil" weeds. That's the difference between script and system programming. When writing scripts, one is only concerned about carrying out a certain task and if anything goes wrong the whole thing can bail. Systems are more robust. When things go wrong they cannot just fail. They need to recover gracefully and do something meaningful in the failed st…

Write an exception handler so you handle the errors.

Plenty of go code doesn't handle errors, just pretends to but doesn't do anything meaningful when they happen.

Re: Mypy 1.6

#95
post #61

Earlier quoted context omitted.

pyright and ruff are my new go to python tools, replacing mypy, pylint, isort and black. So far the only thing that bothers me about pyright is that it can't infer the type of collections based on later insertions. So in something like: lst = [] lst.append(1) lst is of type list[Any] I also program in Rust so I kinda expect this to work :P I asked the maintainer about this and this is apparently by design, though myp…

Ruff is not a replacement for black[^1]. It's also currently complementary to pylint, not a replacement[^2]. I still use those tools with ruff. Further, out of the box, ruff doesn't even replace isort. You have to specifically enable it to sort imports (`I`)[^3]. I personally think that ruff's defaults are much too conservative. I configure it with `ALL` and then ignore the rules I don't want. I _want_ upgrades of ru…

Although it's in alpha, Ruff does have a replacement for Black. https://github.com/astral-sh/ruff/blob/main/crates/ruff_pyth...

Re: Mypy 1.6

#96
post #90
post #68

Earlier quoted context omitted.

`mypy` originally had first-mover advantage, `pyright` has late-mover advantage. Now that we're in the mid-to-late stage of Python typecheckers, `pyright` has a better intercept and slope than `mypy`. I think there'll be one last typechecker to rule them all written in Rust – but we're not there yet, so use `pyright`.

Why would a typechecker written in rust be able to implement a different logic than one written in any other language? And one written in python could just use python for the grammar so it would have the advantage of always loading the code the same exact way as python does.

It would be significantly faster

Re: Mypy 1.6

#97
post #92

Is anyone still using mypy, and if so why? I have replaced it by pyright [0] for a while now, and not looking back. It’s been a faster, more powerful replacement with (in my case), zero downside. [0]: https://github.com/microsoft/pyright

apt install pyright E: Unable to locate package pyright apt install mypy mypy is already the newest version (1.6.0-1).

https://pypi.org/project/pyright/

Re: Mypy 1.6

#98

Earlier quoted context omitted.

TCO is available in Python if you want it. Multiline lambdas can be had by abusing the walrus operator, but in a language that supports nested functions it's a bit pointless. Assuming you meant fluents , you can write most languages in that style if you want to, including Python.

TCO is available if I want it? How? Do you mean writing a slow decorator, that performs some stack magic and that I need to add everywhere? Does it cover all the cases? Like mutually tail recursive functions? Abusing the walrus operator — Well, it is abuse then and hard to read. I actually mean: https://www.gnu.org/software/guile/manual/html_node/Paramete...

It isn't as if Go provides those features, which was the suggested alternative to Python.

Re: Mypy 1.6

#99
post #98

Earlier quoted context omitted.

TCO is available if I want it? How? Do you mean writing a slow decorator, that performs some stack magic and that I need to add everywhere? Does it cover all the cases? Like mutually tail recursive functions? Abusing the walrus operator — Well, it is abuse then and hard to read. I actually mean: https://www.gnu.org/software/guile/manual/html_node/Paramete...

It isn't as if Go provides those features, which was the suggested alternative to Python.

Ah, OK, I guess I lost context there. I was just thinking in general, what I am missing in Python.

Re: Mypy 1.6

#100
post #67

Somewhat offtopic, does anyone have a link to a page that describes which extensions/tools I should be using with VSCode to author Python code? Edited to add: when you read various recommendations, they're all discrete and don't have the overall context. e.g. I installed the VSCode suggested extensions, but then read a comment that I should really be using Ruff. OK, that's good, but if I have extensions X, Y, and Z,…

These pages are naturally out of date from the moment they're written. Caveats aside, I use pyright, ruff and black (although ruff will probably one day consume `black`, entirely) – that's it. `ruff` centralizes a lot of the linter/fixer ecosystem (isort, autoflake, pylint and more). `pyright` is for GoToDefinition and type-checking. `black` is for sanity-checking what `ruff` spits out, and should hopefully not be ne…

Thank you, that description of each extension and how they work together is exactly what I was looking for.

I appreciate you, internet person.

Post reply on HN