Skip to content

Commit 6227fca

Browse files
committed
nits
1 parent 1c18d90 commit 6227fca

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

crates/ty_python_semantic/resources/mdtest/directives/assert_type.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ from typing_extensions import assert_type
1010
def _(x: int):
1111
assert_type(x, int) # fine
1212
assert_type(x, str) # error: [type-assertion-failure]
13+
assert_type(assert_type(x, int), int)
1314
```
1415

1516
## Narrowing

crates/ty_python_semantic/resources/mdtest/snapshots/assert_type.md_-_`assert_type`_-_Basic_(c507788da2659ec9).snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/directives/assert_type.m
1717
3 | def _(x: int):
1818
4 | assert_type(x, int) # fine
1919
5 | assert_type(x, str) # error: [type-assertion-failure]
20+
6 | assert_type(assert_type(x, int), int)
2021
```
2122

2223
# Diagnostics
@@ -31,6 +32,7 @@ error[type-assertion-failure]: Argument does not have asserted type `str`
3132
| ^^^^^^^^^^^^-^^^^^^
3233
| |
3334
| Inferred type of argument is `int`
35+
6 | assert_type(assert_type(x, int), int)
3436
|
3537
info: `str` and `int` are not equivalent types
3638
info: rule `type-assertion-failure` is enabled by default

crates/ty_python_semantic/src/types/infer/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4982,7 +4982,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
49824982
// If there is a single overload that does not match, we still infer the argument
49834983
// types for better diagnostics.
49844984
MatchingOverloadIndex::None => match binding.overloads() {
4985-
[overload] => Some(Either::Left([(overload, binding)].into_iter())),
4985+
[overload] => Some(Either::Left(std::iter::once((overload, binding)))),
49864986
_ => None,
49874987
},
49884988
}

0 commit comments

Comments
 (0)