[TSP] Pyrefly: hover on url_for shows wrong parameter types (bool for str, **kwargs as Module("typing")) (flask)
team needs to reproduce
[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 `url_for`, Pyrefly renders several parameter types incorrectly:
- `_scheme` is `bool` instead of `str`,
- `_external` is `Any` instead of `bool | None`,
- the `**values` keyword parameter type is rendered as `Module("typing")` instead of `Any`,
- and optional parameters use `| Unknown` instead of `| None`.
## 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/helpers.py`.
5. Hover over `url_for` on the line:
```py
def url_for(
```
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
(function) def url_for(
endpoint: str,
*,
_anchor: str | None = None,
_method: str | None = None,
_scheme: str | None = None,
_external: bool | None = None,
**values: Any
) -> str
```
## Actual (Pyrefly over TSP)
```python
(function) def url_for(
endpoint: str,
*,
_anchor: str | Unknown = None,
_method: str | Unknown = None,
_scheme: bool | Unknown = None,
_external: Any = None,
**values: Module("typing")
) -> str
```
Notable problems: `_scheme: bool` (should be `str`), `_external: Any` (should be `bool | None`), and `**values: Module("typing")` (should be `Any`).
## Environment
- Pyrefly: `pyrefly 1.1.1`
- `python.analysis` Python version: 3.11
- OS: Windows
0 条评论