Closed4

静的型チェッカのPyreflyを使ってみる

HirokiHiroki

とりあえずPyreflyを入れてみて

uv add pyrefly
uv sync

サンプルコードを書いて

def sample(hoge: str) -> None:
    print(hoge)

sample(123)

チェックしてみると

uv run pyrefly check

以下の結果

INFO Found `/home/{user-name}/work/pyrefly-test/pyproject.toml` marking project root, checking root directory with default configuration
ERROR /home/{user-name}/work/pyrefly-test/main.py:4:8-11: Argument `Literal[123]` is not assignable to parameter `hoge` with type `str` in function `sample` [bad-argument-type]
 INFO 1 errors shown, 0 errors ignored, 1 modules, 58 transitive dependencies, 17,356 lines, took 0.13s, peak memory physical 65.7 MiB
HirokiHiroki

VS Codeのプラグインも入れてみた。

このスクラップは3ヶ月前にクローズされました