Skip to content

Commit

Permalink
Add test if second argument is not a type
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Oct 23, 2024
1 parent 8a46907 commit 86f37ad
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ if imported_isinstance(x, int):
reveal_type(x) # revealed: Literal[1]
```

## Do not narrow if second argument is not a type

```py
x = 1 if flag else "a"

# TODO: this should cause us to emit a diagnostic during
# type checking
if isinstance(x, "a"):
reveal_type(x) # revealed: Literal[1] | Literal["a"]
```

## Do not narrow if there are keyword arguments

```py
Expand Down

0 comments on commit 86f37ad

Please sign in to comment.