
"Installing Pyrefly with UV My project uses `uv` for package management. To install `pyrefly` as a development-only dependency, I ran the following command: ```sh uv add pyrefly --dev ``` `pyrefly` is a Rust-based Python tool, so its package includes pre-compiled binaries. This makes the package larger (around 10MB) than a pure Python equivalent. This can be an issue with a slower connection. However, `uv` caches the downloaded package, making subsequent installations of the same version much faster."
"Running the First Type Check With `pyrefly` installed, I ran the first check across the entire project. ```sh uv run pyrefly check . ``` The initial scan found 31 errors. To make the task more manageable, I narrowed the scope to just the main application file. ```sh uv run pyrefly check main.py ``` This reduced the list to 11 errors, giving me a focused starting point."
"`pyrefly` pointed out an issue with the `get_post` function. Here's the pyrefly output ```sh ERROR Type `None` is not iterable [not-iterable] --> main.py:258:9 | 258 | content, metadata = get_post(slug) | ^^^^^^^^^^^^^^^^^ | ``` The function's type hint declared that it returns a `tuple` or `None`. However, after reviewing the code, I saw that the function never actually returns `None`. If a post is not found, it raises a `ContentNotFound` exception."
Static type checking was added to a blog engine project using pyrefly, a fast Rust-based type checker for Python. pyrefly was installed as a development dependency with uv, noting that pre-compiled binaries increase package size (about 10MB) while uv caching speeds subsequent installs. An initial pyrefly scan reported 31 errors; narrowing the check to main.py reduced errors to 11. pyrefly reported that None was not iterable when unpacking get_post(slug). The get_post annotation allowed tuple | None, but the function never returns None and raises ContentNotFound instead. The incorrect type hint was corrected to match runtime behavior. Commands used included uv add pyrefly --dev and uv run pyrefly check . and uv run pyrefly check main.py.
Read at https://daniel.feldroy.com
Unable to calculate read time
Collection
[
|
...
]