facebook / facebook/pyrefly

False positive "Function declared to return `Never` but is missing an explicit `return`"

Open
#4,176 10 comments 0 reactions 1 assignee Claimed by @mwestbroek View on GitHub
good first issue stale typechecking
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

```python
from typing import Never

def foo() -> Never:
print("hello")

foo()
```

Python: 3.12

We probably shouldn't give this error if the expected return is Never

### Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0A5GADcYlADrpJmGGDphcuABQBKOgFoAfIJFjEkuobrFKrBkvEgAFjChRcllZMkLlKkABoQZSrKilCBlooCgBiOgAFUl8wfzo0LDx8OgBjXHRINgBXSlQGCHTCSXCAZRgYOisGBmI4RAB6ep8-AN42eph0esxcFLh6tIyIbNz89Pr5XjpUYVRoVGxYVPTMnLyC9DpcYjH0OCL0MgYrdPVRSjgNugBeOksAZkIARgAmS0kAbTFqC4BdSSy6C4PD4MEw6kwEF8KXyohudAA5MN0LwYAjJCiGOpfABHLJQsHqADWMFI6lQKRS8Dg8IRAHdUJR0Oj0CAAL5eCmwmAAMWgMAoCRwBBI5DZQA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.