Skip to content

Commit efca8ac

Browse files
committed
.
1 parent b601c58 commit efca8ac

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

test-data/unit/check-narrowing.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,14 +3177,14 @@ class B: ...
31773177

31783178
T = TypeVar("T")
31793179

3180-
def bad1(self, obj: T) -> T:
3180+
def forgets_about_subclasses1(self, obj: T) -> T:
31813181
if isinstance(obj, A):
31823182
return A() # E: Incompatible return value type (got "A", expected "T")
31833183
elif isinstance(obj, B):
31843184
return B() # E: Incompatible return value type (got "B", expected "T")
31853185
raise
31863186

3187-
def f1(self, obj: T) -> T:
3187+
def correct1(self, obj: T) -> T:
31883188
if type(obj) == A:
31893189
return A() # E: Incompatible return value type (got "A", expected "T")
31903190
elif type(obj) == B:
@@ -3193,14 +3193,14 @@ def f1(self, obj: T) -> T:
31933193

31943194
T_value = TypeVar("T_value", A, B)
31953195

3196-
def bad2(self, obj: T_value) -> T_value:
3196+
def forgets_about_subclasses2(self, obj: T_value) -> T_value:
31973197
if isinstance(obj, A):
31983198
return A() # E: Incompatible return value type (got "A", expected "B")
31993199
elif isinstance(obj, B):
32003200
return B()
32013201
raise
32023202

3203-
def f2(self, obj: T_value) -> T_value:
3203+
def correct2(self, obj: T_value) -> T_value:
32043204
if type(obj) == A:
32053205
return A()
32063206
elif type(obj) == B:

0 commit comments

Comments
 (0)