# pyre 使ってみた - [Pyre · A performant typechecker for Python](https://pyre-check.org/) OCaml で書かれた Python 型チェックツール。Facebook 製。FlowType の用な感じで使えそう。 mypy があるが、こちらはおそらく高速を売りにしている気がする。たぶん。 [python/mypy: Optional static typing for Python 2 and 3 \(PEP484\)](https://github.com/python/mypy) ## URL とか - [Pyre: Fast Type Checking for Python](https://www.facebook.com/notes/protect-the-graph/pyre-fast-type-checking-for-python/2048520695388071/) - [facebook/pyre\-check: Performant type\-checking for python\.](https://github.com/facebook/pyre-check) - [PEP 484 \-\- Type Hints \| Python\.org](https://www.python.org/dev/peps/pep-0484/) - [PEP 526 \-\- Syntax for Variable Annotations \| Python\.org](https://www.python.org/dev/peps/pep-0526/) ## インストール ``` pip install pyre-check ``` ## セットアップ ``` pyre init ``` ## 使ってみる spam.py を作る、ちょっと型間違えてみる。 ``` def main() -> int: return "" ``` pyre 実行してみる、ちゃんと怒られる。 ``` $ pyre ƛ Waiting for server... ƛ Found 1 type error! spam.py:2:4 Incompatible return type [7]: Expected `int` but got `str`. ``` 型を str にする ``` def main() -> str: return "" ``` で、再度実行してみる。 ``` $ pyre ƛ Waiting for server... ƛ No type errors found ``` エラーなくなった。