ITADN

[TSP] Pyrefly: hover shows Unknown instead of None for optional params/return; self shown as bare class (flask Flask.run)

#8092Openrchiodo 创建于 2026-06-30
team needs to reproduce
R
rchiodocommented
[TSP] Found via differential testing comparing Pylance's built-in Pyright analyzer against [Pyrefly](https://github.com/facebook/pyrefly) running as an external type server over the Type Server Protocol (TSP). ## Summary On hover over a method, Pyrefly: - renders optional parameters as `<type> | Unknown` instead of `<type> | None`, - renders the return type as `Unknown` instead of `None`, and - renders the `self` parameter as the bare class (`Flask`) instead of `Self@Flask`. ## Repro 1. `git clone https://github.com/pallets/flask.git` 2. `git checkout c12a5d874c5a014495eb2db8a73f40037bc813ac` (3.0.3) 3. Create a venv and `pip install -e .` 4. Open `src/flask/app.py`. 5. Hover over `run` on the line: ```py def run( ``` To switch backends: set `python.analysis.typeServerExecutable` to the Pyrefly binary to get the Pyrefly result; leave it unset to get the built-in (Pyright) result. ## Expected (Pylance / built-in Pyright) ```python (method) def run( self: Self@Flask, host: str | None = None, port: int | None = None, debug: bool | None = None, load_dotenv: bool = True, **options: Any ) -> None ``` ## Actual (Pyrefly over TSP) ```python (method) def run( self: Flask, host: str | Unknown = None, port: int | Unknown = None, debug: bool | Unknown = None, load_dotenv: bool = True, **options: Any ) -> Unknown ``` `Unknown` appears where `None` is expected (parameter defaults and the return type), and `self` is `Flask` instead of `Self@Flask`. ## Environment - Pyrefly: `pyrefly 1.1.1` - `python.analysis` Python version: 3.11 - OS: Windows
0 条评论