Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions conformance/third_party/conformance.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10830,17 +10830,6 @@
],
"specialtypes_any.py": [],
"specialtypes_never.py": [
{
"code": -2,
"column": 22,
"concise_description": "Function declared to return `NoReturn` but is missing an explicit `return`",
"description": "Function declared to return `NoReturn` but is missing an explicit `return`",
"line": 19,
"name": "bad-return",
"severity": "error",
"stop_column": 30,
"stop_line": 19
},
{
"code": -2,
"column": 21,
Expand Down
4 changes: 3 additions & 1 deletion conformance/third_party/conformance.result
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@
"qualifiers_final_annotation.py": [],
"qualifiers_final_decorator.py": [],
"specialtypes_any.py": [],
"specialtypes_never.py": [],
"specialtypes_never.py": [
"Line 19: Expected 1 errors"
],
"specialtypes_none.py": [],
"specialtypes_promotions.py": [],
"specialtypes_type.py": [],
Expand Down
12 changes: 6 additions & 6 deletions conformance/third_party/results.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"total": 140,
"pass": 134,
"fail": 6,
"pass_rate": 0.96,
"differences": 13,
"pass": 133,
"fail": 7,
"pass_rate": 0.95,
"differences": 14,
"passing": [
"aliases_explicit.py",
"aliases_implicit.py",
Expand Down Expand Up @@ -117,7 +117,6 @@
"qualifiers_final_annotation.py",
"qualifiers_final_decorator.py",
"specialtypes_any.py",
"specialtypes_never.py",
"specialtypes_none.py",
"specialtypes_promotions.py",
"specialtypes_type.py",
Expand Down Expand Up @@ -146,7 +145,8 @@
"constructors_callable.py": 2,
"dataclasses_descriptors.py": 2,
"exceptions_context_managers.py": 2,
"generics_scoping.py": 4
"generics_scoping.py": 4,
"specialtypes_never.py": 1
},
"comment": "@generated"
}
4 changes: 4 additions & 0 deletions pyrefly/lib/alt/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5435,6 +5435,10 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
);
}
} else {
// If the annotation is `NoReturn` or `Never` and there is no explicit return, there is no need to check further.
if annotation.is_never() && !has_explicit_returns {
return;
}
self.check_type(implicit_return.ty(), annotation, range, errors, &|| {
TypeCheckContext::of_kind(TypeCheckKind::ImplicitFunctionReturn(
has_explicit_returns,
Expand Down
10 changes: 10 additions & 0 deletions pyrefly/lib/test/returns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,16 @@ def g():
"#,
);

testcase!(
test_no_explicit_return_if_return_type_is_never,
r#"
from typing import Never

def f() -> Never:
print("hello")
"#,
);

testcase!(
test_return_no_error,
r#"
Expand Down
Loading