## 経緯 こちらの記事を見て気になった。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://astral.sh/static/favicon-32x32.png" /> <span class="link-card-v2-site-name">astral.sh</span> </div> <div class="link-card-v2-title"> ty: An extremely fast Python type checker and language server </div> <div class="link-card-v2-content"> ty is an extremely fast Python type checker and language server, written in Rust, and designed as an alternative ... </div> <img class="link-card-v2-image" src="https://astral.sh/static/OpenGraph/Astral.jpg" /> <a href="https://astral.sh/blog/ty"></a> </div> 最近は仕事で[[Django]]を書くために[[Pyright]]を使っているが、[[VSCode]]勢の[[Pylance]]と比べると[[Django]]をサポートしきれていない点もあり気になっていた。 [[ty]]は高速そうだし、エラーメッセージも分かりやすそうで将来性もある。しかも、[[Pydantic]]や[[Django]]はfirst-class supportする予定があるらしい。 > Following the Beta release, our immediate priority is supporting early adopters. From there, we're working towards a Stable release next year, with the gap between the [Beta](https://github.com/astral-sh/ty/milestone/2) and [Stable](https://github.com/astral-sh/ty/milestone/4) milestones largely focusing on: (1) stability and bug fixes, (2) completing the long tail of features in the [Python typing specification](https://github.com/astral-sh/ty/issues/1889), and (3) first-class support for popular third-party libraries like [Pydantic](https://pypi.org/project/pydantic/) and [Django](https://pypi.org/project/Django/). > > *[ty: An extremely fast Python type checker and language server](https://astral.sh/blog/ty)* [[Pyright]]の後釜として個人的にはすごく期待しているので。 ## 環境 | 対象 | バージョン | | ------------------ | --------- | | [[macOS]] | 15.7.2 | | [[ty]] | 0.0.2 | | [[pipx]] | 1.8.0 | | [[Neovim]] | 0.11.4 | | [[nvim-lspconfig]] | `ad95655` | ## インストール [[mise]]の[[Backends (mise)|Backends]]で[[pipx]]を使う。 ```console mise use -g pipx mise use -g pipx:ty ``` バージョン確認。めっちゃバージョン低い。 ```console $ ty --version ty 0.0.2 (42835578d 2025-12-16) ``` ## [[Neovim]]の設定 [[nvim-lspconfig]]のドキュメントを参考に。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" /> <span class="link-card-v2-site-name">GitHub</span> </div> <div class="link-card-v2-title"> nvim-lspconfig/doc/configs.md at master · neovim/nvim-lspconfig </div> <div class="link-card-v2-content"> Quickstart configs for Nvim LSP. Contribute to neovim/nvim-lspconfig development by creating an account on GitHu ... </div> <img class="link-card-v2-image" src="https://opengraph.githubassets.com/3a98b4456d97ab1fcf7326aa45af41f8354cf054a7aa590e410534ccf05b4ea0/neovim/nvim-lspconfig" /> <a href="https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#ty"></a> </div> 特別な設定は必要なさそうなのでファイルだけ。 `after/lsp/ty.lua` ```lua return {} ``` [[Pyright]]をコメントアウトして[[ty]]を追加。 `lua/lsp.lua` ```lua vim.lsp.enable({ -- 中略 -- "pyright", -- 中略 "ty", -- 中略 }) ``` ## 良いところ 型情報は引数情報が[[rust-analyzer]]みたく表示されるところ。人によっては邪魔かもしれないが...。 ![[2025-12-17-21-20-46.avif]] `ty check` コマンドによるチェックの結果も見やすい。 ![[2025-12-17-21-28-13.avif]] ## 気になるところ 型の絞り込みが弱い。 ![[2025-12-17-21-22-53.avif]] [[Pyright]]だとしっかり絞り込める。 ![[2025-12-17-21-23-22.avif]] [[Pyright]]は[[パターンマッチ (Python)|パターンマッチ]]にも対応している。 ![[2025-12-17-21-24-05.avif]] ## 総括 v0.0.2ということもあり、まだまだこれからではあるが、基本的な[[Language Server]]としての利用はできているイメージ。[[型ヒント]]をしっかりやっている実務だとまだ時期早々かと思うが、ちょっとしたものであれば快適に使えるかもしれない。 またしばらくしたらキャッチアップしてみる。