Skip to content

Commit ec94017

Browse files
committed
Make things actually work
1 parent bcaa4c9 commit ec94017

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

mypy/checkmember.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ def analyze_type_callable_member_access(name: str, typ: FunctionLike, mx: Member
367367
ret_type = tuple_fallback(ret_type)
368368
if isinstance(ret_type, TypedDictType):
369369
ret_type = ret_type.fallback
370+
if isinstance(ret_type, LiteralType):
371+
ret_type = ret_type.fallback
370372
if isinstance(ret_type, Instance):
371373
if not mx.is_operator:
372374
# When Python sees an operator (eg `3 == 4`), it automatically translates that

mypy/typeops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def class_callable(
193193
default_ret_type = fill_typevars(info)
194194
explicit_type = init_ret_type if is_new else orig_self_type
195195
if (
196-
isinstance(explicit_type, (Instance, TupleType, UninhabitedType))
196+
isinstance(explicit_type, (Instance, TupleType, UninhabitedType, LiteralType))
197197
# We have to skip protocols, because it can be a subtype of a return type
198198
# by accident. Like `Hashable` is a subtype of `object`. See #11799
199199
and isinstance(default_ret_type, Instance)

mypy/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,6 +1916,8 @@ def type_object(self) -> mypy.nodes.TypeInfo:
19161916
ret = ret.partial_fallback
19171917
if isinstance(ret, TypedDictType):
19181918
ret = ret.fallback
1919+
if isinstance(ret, LiteralType):
1920+
ret = ret.fallback
19191921
assert isinstance(ret, Instance)
19201922
return ret.type
19211923

0 commit comments

Comments
 (0)