Pyre: A performant type-checker for Python 3
21–30 of 118 posts
Re: Pyre: A performant type-checker for Python 3
#22As with package managers, there seem to be half a dozen different, competing type checkers for Python now...
Re: Pyre: A performant type-checker for Python 3
#23PyCharm works well for me. Probably not as fancy as all this other stuff, but the type hints make the code easier to understand, and they help PyCharm help me by enabling it to find more errors and by enabling enhanced autocompletion.
Re: Pyre: A performant type-checker for Python 3
#24Earlier quoted context omitted.
Last I checked, mypy struggled to represent recursive types. Think `JSON = Union[None, bool, str, float, int, List['JSON'], Dict[str, 'JSON']`. That's a bummer because recursive data types are darn handy. Worse, importing third party packages often fails silently and when you can get error messages they tend to be completely inactionable (I recall one error message which linked to a web page that had lots of details…
I have yet to successfully build a project with the strict mypy settings, without resorting to either turning some off or having to use an explicit Any. And a lot of the non-default settings are absolutely critical if you care about correctness. Lack of recursive types has been a major deal breaker for me. If you have a class Foo that can construct a class Bar, and a class Bar that can construct a class Foo, you can'…
from __future__ import annotations
class X:
def __init__(self, value: int) -> None:
self.value = value
def to_y(self) -> Y:
return Y(self.value)
class Y:
def __init__(self, value: int) -> None:
self.value = value
def to_x(self) -> X:
return X(self.value)
x = X(10).to_y().to_x()
print(x.value)Re: Pyre: A performant type-checker for Python 3
#25Big discussion with over 500 comments from 3 years ago: https://news.ycombinator.com/item?id=17048446
So three years passed and static checkers have gotten even more traction. What's the best option for Python so far for small projects today? I tried mypy [1] before but it was a bit cumbersome to keep it checking my code. At work I use pytype [2]. It's good enough but that's only because someone else made a build system integration for me. Pyre's scan-all-the-files approach seems easier to get started. Is there any c…
Re: Pyre: A performant type-checker for Python 3
#26Earlier quoted context omitted.
I've used mypy and pyright. Mypy generally "just works" for all the Python idioms I use, while pyright is less reliable. Pyright's VSCode integration, Pylance, provides a great auto complete experience. So I use Pyright for autocomplete in VSCode and mypy for type checking.
Last I checked, mypy struggled to represent recursive types. Think `JSON = Union[None, bool, str, float, int, List['JSON'], Dict[str, 'JSON']`. That's a bummer because recursive data types are darn handy. Worse, importing third party packages often fails silently and when you can get error messages they tend to be completely inactionable (I recall one error message which linked to a web page that had lots of details…
I'm planning to migrate this to my own blog soon.
Re: Pyre: A performant type-checker for Python 3
#27Earlier quoted context omitted.
I have yet to successfully build a project with the strict mypy settings, without resorting to either turning some off or having to use an explicit Any. And a lot of the non-default settings are absolutely critical if you care about correctness. Lack of recursive types has been a major deal breaker for me. If you have a class Foo that can construct a class Bar, and a class Bar that can construct a class Foo, you can'…
I also struggle with Mypy's strict mode, but I think recursive types are different from classes that can construct each other. Mypy doesn't have any problem with the following code from __future__ import annotations class X: def __init__(self, value: int) -> None: self.value = value def to_y(self) -> Y: return Y(self.value) class Y: def __init__(self, value: int) -> None: self.value = value def to_x(self) -> X: retur…
Re: Pyre: A performant type-checker for Python 3
#28As with package managers, there seem to be half a dozen different, competing type checkers for Python now...
Yeah and even worse they disagree about type errors! We really need a modern Python alternative. I don't know of any that don't give up the REPL / single file script features which are pretty huge advantages of Python to be honest.
Re: Pyre: A performant type-checker for Python 3
#29As with package managers, there seem to be half a dozen different, competing type checkers for Python now...
Yeah and even worse they disagree about type errors! We really need a modern Python alternative. I don't know of any that don't give up the REPL / single file script features which are pretty huge advantages of Python to be honest.
Re: Pyre: A performant type-checker for Python 3
#30As with package managers, there seem to be half a dozen different, competing type checkers for Python now...
Yeah and even worse they disagree about type errors! We really need a modern Python alternative. I don't know of any that don't give up the REPL / single file script features which are pretty huge advantages of Python to be honest.
Then there is Julia as well.