TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Pyright: Static Type Checker for Python

152 pointsby pen2lover 2 years ago

13 comments

eatonphilover 2 years ago
To the obvious question: how does this differ from mypy?<p>tldr; mostly about performance improvements but there&#x27;s also semantic differences. The latter sounds like it means a split between the community who decides to do mypy vs pyright. But maybe pyright only differs with mypy in terms of things that are considered bugs in mypy, and things that are optional in mypy (via flags).<p><a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;pyright&#x2F;blob&#x2F;main&#x2F;docs&#x2F;mypy-comparison.md">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;pyright&#x2F;blob&#x2F;main&#x2F;docs&#x2F;mypy-com...</a>.
评论 #34223049 未加载
评论 #34223163 未加载
评论 #34223053 未加载
评论 #34223330 未加载
samwillisover 2 years ago
From this comparison (<a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;pyright&#x2F;blob&#x2F;main&#x2F;docs&#x2F;mypy-comparison.md">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;pyright&#x2F;blob&#x2F;main&#x2F;docs&#x2F;mypy-com...</a>) it looks like Pyright fixes a load of issues that MyPy has. It also seems much closer to how TypeScript works (I have worked significantly more with TypeScript than typed Python and really like it)<p>Is there a reason <i>not</i> to go with Pyright and stick with MyPy?
评论 #34223356 未加载
评论 #34223651 未加载
评论 #34225463 未加载
pedrovhbover 2 years ago
I&#x27;ve been using pyright more than mypy these days; playing with higher order functions I have pulled about half of my hair out because of things that more often than not turn out to be mypy bugs. I&#x27;ve tried pyre, and that&#x27;s better too, in my experience. The codebases of mypy and pyre are starkly different in terms of organization (though pyre does the heavy lifting in OCaml). Haven&#x27;t looked at pyright&#x27;s yet.<p>Besides the bug count, it&#x27;s kind of weird to see the &quot;reference&quot; type checker for Python constantly lagging behind in terms of features, experimental ones but also ones that have already been accepted PEPs for a while. Meanwhile pyre and pyright both have usually had features for _months_ before mypy has even started implementing them.<p>As a side question, does anyone know how I can easily interface with an LSP client from Python? I&#x27;m itching to build something that gives me some custom typing insight as I write code, and it&#x27;s probably more robust to consult LSP than to parse CLI output.
评论 #34226990 未加载
wcdolphinover 2 years ago
Has anyone migrated a large code base between MyPy and Pyright? In particular would love to hear about experiences with Django. Mypy’s performance and the join based type merging are quite limiting. At the same time, the ecosystem support around MyPy seems strong.
评论 #34223278 未加载
评论 #34223647 未加载
threadweaver34over 2 years ago
I can&#x27;t decide if it&#x27;s a feature or a bug that there are at least 3 major type checkers for Python.
评论 #34224196 未加载
nezirusover 2 years ago
I can vouch for use of Pyright as LSP for neovim and helix. Very useful, especially the strict mode.<p>I usually pair it with pyre, another great tool<p><a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;pyre-check">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;pyre-check</a>
评论 #34247477 未加载
toinbisover 2 years ago
I use both mypy and pyright. Pre-commit hook&#x2F;vscode runs checks for mypy, pyright, as well as pylint, flake8, black, bandit.<p>Why both? I just have more confidence in getting feedback from both of the tools.
chaychoongover 2 years ago
For Neovim users that use LSP + completion + snippets, it is slightly unfortunate that the Pyright team does not plan to support snippets on Pyright (but open to supporting it on Pylance, which is not OSS).<p><a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;pyright&#x2F;issues&#x2F;924">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;pyright&#x2F;issues&#x2F;924</a>
dangover 2 years ago
Related:<p><i>Pyright: Static type checker for Python</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19473631" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19473631</a> - March 2019 (87 comments)<p>Also:<p><i>Using Mypy in Production</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32556816" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=32556816</a> - Aug 2022 (129 comments)<p><i>Exhaustiveness Checking with Mypy</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25428583" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25428583</a> - Dec 2020 (19 comments)<p><i>Applying Mypy to real-world projects</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22302789" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=22302789</a> - Feb 2020 (23 comments)<p><i>Statically-typed error handling in Python using Mypy</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21736620" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21736620</a> - Dec 2019 (126 comments)<p><i>Pytype – A static type analyzer for Python code</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19476605" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19476605</a> - March 2019 (29 comments)<p><i>Pyre: Facebook&#x27;s static type checker for Python</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19476286" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19476286</a> - March 2019 (2 comments)<p><i>Type hints cheat sheet (Python 3)</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18660309" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18660309</a> - Dec 2018 (18 comments)<p><i>PyAnnotate – Auto-generate type annotations for mypy</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15707877" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15707877</a> - Nov 2017 (33 comments)<p><i>Static types in Python</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12703008" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12703008</a> - Oct 2016 (221 comments)<p><i>Typed Python: new Mypy release</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11641245" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11641245</a> - May 2016 (46 comments)<p><i>Mypy 0.3 Released – optional static type checker for Python</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11134647" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11134647</a> - Feb 2016 (19 comments)<p><i>Mypy – static type checking for Python 3</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8191916" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8191916</a> - Aug 2014 (29 comments)<p><i>Mypy - An experimental Python variant with dynamic and static typing</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4561973" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4561973</a> - Sept 2012 (39 comments)
kelsolaarover 2 years ago
Moved Colour to Pyright a few weeks ago, our Mypy checks on Github Actions were taking 1h30. Those speed regressions were fixed recently though but Pyright is still much faster and seems stricter, finding more legit issues than Mypy.
29athrowawayover 2 years ago
Microsoft: &quot;Where do you want to go today?&quot;<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;T4oNA8ViuwI?t=63" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;T4oNA8ViuwI?t=63</a>
tlarkworthyover 2 years ago
It&#x27;s written in Typescript I would love to type check python in the browser without running pyodine, does anyone know how?
评论 #34226056 未加载
评论 #34225126 未加载
gjvcover 2 years ago
better (more suggestive) name than &quot;mypy&quot;