Skip to content

Commit 8792bd6

Browse files
committed
.
1 parent 06a4165 commit 8792bd6

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

mypy/checkexpr.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,15 +1821,7 @@ def check_callable_call(
18211821
):
18221822
proper_arg = get_proper_type(arg_types[0])
18231823
if isinstance(proper_arg, Instance) and proper_arg.type.is_protocol:
1824-
callee = callee.copy_modified(
1825-
ret_type=UnionType(
1826-
[
1827-
self.named_type("builtins.type"),
1828-
self.named_type("types.ModuleType"),
1829-
AnyType(TypeOfAny.special_form),
1830-
]
1831-
)
1832-
)
1824+
callee = callee.copy_modified(ret_type=self.named_type("builtins.type"))
18331825
else:
18341826
callee = callee.copy_modified(ret_type=TypeType.make_normalized(arg_types[0]))
18351827

test-data/unit/check-protocols.test

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4249,8 +4249,8 @@ import mod
42494249

42504250
a: P = mod
42514251
value = type(a)
4252-
reveal_type(value) # N: Revealed type is "Union[builtins.type, types.ModuleType, Any]"
4253-
reveal_type(value.foo) # E: Item "type" of "Union[type, Module, Any]" has no attribute "foo" \
4252+
reveal_type(value) # N: Revealed type is "builtins.type"
4253+
reveal_type(value.foo) # E: "type" has no attribute "foo" \
42544254
# N: Revealed type is "Any"
42554255

42564256
class Namespace: ...
@@ -4259,13 +4259,14 @@ n.foo = lambda: None # E: "Namespace" has no attribute "foo"
42594259

42604260
b: P = cast(Any, n)
42614261
value = type(b)
4262-
reveal_type(value) # N: Revealed type is "Union[builtins.type, types.ModuleType, Any]"
4263-
reveal_type(value.foo) # E: Item "type" of "Union[type, Module, Any]" has no attribute "foo" \
4262+
reveal_type(value) # N: Revealed type is "builtins.type"
4263+
reveal_type(value.foo) # E: "type" has no attribute "foo" \
42644264
# N: Revealed type is "Any"
42654265
[file mod.py]
42664266
def foo() -> None: ...
42674267

42684268
[builtins fixtures/tuple.pyi]
4269+
42694270
[case testOverloadProtocolSubtyping]
42704271
from typing import Protocol, Self, overload
42714272

0 commit comments

Comments
 (0)