8000 Reject Type[U] where U's bound is a generic class. · python/mypy@f596dc6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f596dc6

Browse files
author
Guido van Rossum
committed
Reject Type[U] where U's bound is a generic class.
1 parent f84c64d commit f596dc6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mypy/checkexpr.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,12 @@ def analyze_type_type_callee(self, item: Type, context: Context) -> Type:
304304
# but better than AnyType...), but replace the return type
305305
# with typevar.
306306
callee = self.analyze_type_type_callee(item.upper_bound, context)
307-
# XXX What to do for a generic class? Maybe just reject.
308-
if isinstance(callee, CallableType):
309-
callee = callee.copy_modified(ret_type=item)
310-
# XXX What to do for Overloaded?
311-
return callee
307+
if not isinstance(callee, CallableType):
308+
# Might be a union.
309+
# XXX What to do for Overloaded?
310+
return callee
311+
if not callee.is_generic():
312+
return callee.copy_modified(ret_type=item)
312313

313314
self.msg.unsupported_type_type(item, context)
314315
return AnyType()

0 commit comments

Comments
 (0)
0