From befc7b75abc366e5a9403bf210d2b5d20ed32306 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 18 Jan 2023 08:55:44 +0100 Subject: [PATCH] Use return type of `__new__` for any type --- mypy/typeops.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mypy/typeops.py b/mypy/typeops.py index 8c01fb118076..158deb2400a2 100644 --- a/mypy/typeops.py +++ b/mypy/typeops.py @@ -175,8 +175,6 @@ def class_callable( variables.extend(info.defn.type_vars) variables.extend(init_type.variables) - from mypy.subtypes import is_subtype - init_ret_type = get_proper_type(init_type.ret_type) orig_self_type = get_proper_type(orig_self_type) default_ret_type = fill_typevars(info) @@ -187,9 +185,6 @@ def class_callable( # by accident. Like `Hashable` is a subtype of `object`. See #11799 and isinstance(default_ret_type, Instance) and not default_ret_type.type.is_protocol - # Only use the declared return type from __new__ or declared self in __init__ - # if it is actually returning a subtype of what we would return otherwise. - and is_subtype(explicit_type, default_ret_type, ignore_type_params=True) ): ret_type: Type = explicit_type else: