8000 Add unit test · python/mypy@79a8085 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 79a8085

Browse files
committed
Add unit test
1 parent 078879e commit 79a8085

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

test-data/unit/check-isinstance.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,3 +1344,11 @@ def f(x: object) -> None:
13441344
reveal_type(b) # E: Revealed type is '__main__.A'
13451345
[builtins fixtures/isinstance.pyi]
13461346
[out]
1347+
1348+
[case testIsInstanceWithTypeVariable]
1349+
from typing import *
1350+
def f(x: Union[int, str], typ: type) -> None:
1351+
if isinstance(x, (typ, int)):
1352+
x + 1 # E: Unsupported operand types for + (likely involving Union)
1353+
[builtins fixtures/isinstancelist.pyi]
1354+

test-data/unit/fixtures/isinstancelist.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import builtinclass, Iterable, Iterator, Generic, TypeVar, List, Mapping, overload, Tuple
1+
from typing import builtinclass, Iterable, Iterator, Generic, TypeVar, List, Mapping, overload, Tuple, Set, Union
22

33
@builtinclass
44
class object:
@@ -11,7 +11,7 @@ class type:
1111
class tuple: pass
1212
class function: pass
1313

14-
def isinstance(x: object, t: type) -> bool: pass
14+
def isinstance(x: object, t: Union[type, Tuple]) -> bool: pass
1515

1616
@builtinclass
1717
class int:
@@ -42,3 +42,9 @@ class dict(Iterable[KT], Mapping[KT, VT], Generic[KT, VT]):
4242
def __setitem__(self, k: KT, v: VT) -> None: pass
4343
def __iter__(self) -> Iterator[KT]: pass
4444
def update(self, a: Mapping[KT, VT]) -> None: pass
45+
46+
class set(Iterable[T], Generic[T]):
47+
def __iter__(self) -> Iterator[T]: pass
48+
def add(self, x: T) -> None: pass
49+
def discard(self, x: T) -> None: pass
50+
def update(self, x: Set[T]) -> None: pass

0 commit comments

Comments
 (0)
0