|
129 | 129 | validate_instance, |
130 | 130 | ) |
131 | 131 | from mypy.typeops import ( |
132 | | - bind_self, |
133 | 132 | callable_type, |
134 | 133 | custom_special_method, |
135 | 134 | erase_to_union_or_bound, |
@@ -1517,15 +1516,6 @@ def check_call_expr_with_callee_type( |
1517 | 1516 | object_type=object_type, |
1518 | 1517 | ) |
1519 | 1518 | proper_callee = get_proper_type(callee_type) |
1520 | | - if isinstance(e.callee, (NameExpr, MemberExpr)): |
1521 | | - node = e.callee.node |
1522 | | - if node is None and member is not None and isinstance(object_type, Instance): |
1523 | | - if (symbol := object_type.type.get(member)) is not None: |
1524 | | - node = symbol.node |
1525 | | - self.chk.check_deprecated(node, e) |
1526 | | - self.chk.warn_deprecated_overload_item( |
1527 | | - node, e, target=callee_type, selftype=object_type |
1528 | | - ) |
1529 | 1519 | if isinstance(e.callee, RefExpr) and isinstance(proper_callee, CallableType): |
1530 | 1520 | # Cache it for find_isinstance_check() |
1531 | 1521 | if proper_callee.type_guard is not None: |
@@ -2943,6 +2933,8 @@ def infer_overload_return_type( |
2943 | 2933 | # check for ambiguity due to 'Any' below. |
2944 | 2934 | if not args_contain_any: |
2945 | 2935 | self.chk.store_types(m) |
| 2936 | + if isinstance(infer_type, ProperType) and isinstance(infer_type, CallableType): |
| 2937 | + self.chk.check_deprecated(infer_type.definition, context) |
2946 | 2938 | return ret_type, infer_type |
2947 | 2939 | p_infer_type = get_proper_type(infer_type) |
2948 | 2940 | if isinstance(p_infer_type, CallableType): |
@@ -2979,6 +2971,11 @@ def infer_overload_return_type( |
2979 | 2971 | else: |
2980 | 2972 | # Success! No ambiguity; return the first match. |
2981 | 2973 | self.chk.store_types(type_maps[0]) |
| 2974 | + inferred_callable = inferred_types[0] |
| 2975 | + if isinstance(inferred_callable, ProperType) and isinstance( |
| 2976 | + inferred_callable, CallableType |
| 2977 | + ): |
| 2978 | + self.chk.check_deprecated(inferred_callable.definition, context) |
2982 | 2979 | return return_types[0], inferred_types[0] |
2983 | 2980 |
|
2984 | 2981 | def overload_erased_call_targets( |
@@ -4103,16 +4100,6 @@ def lookup_definer(typ: Instance, attr_name: str) -> str | None: |
4103 | 4100 | errors.append(local_errors.filtered_errors()) |
4104 | 4101 | results.append(result) |
4105 | 4102 | else: |
4106 | | - if isinstance(obj, Instance) and isinstance( |
4107 | | - defn := obj.type.get_method(name), OverloadedFuncDef |
4108 | | - ): |
4109 | | - for item in defn.items: |
4110 | | - if ( |
4111 | | - isinstance(item, Decorator) |
4112 | | - and isinstance(typ := item.func.type, CallableType) |
4113 | | - and bind_self(typ) == result[1] |
4114 | | - ): |
4115 | | - self.chk.check_deprecated(item.func, context) |
4116 | 4103 | return result |
4117 | 4104 |
|
4118 | 4105 | # We finish invoking above operators and no early return happens. Therefore, |
@@ -6043,8 +6030,10 @@ def accept( |
6043 | 6030 | # We cannot use cache inside lambdas, because they skip immediate type |
6044 | 6031 | # context, and use enclosing one, see infer_lambda_type_using_context(). |
6045 | 6032 | # TODO: consider using cache for more expression kinds. |
6046 | | - elif isinstance(node, (CallExpr, ListExpr, TupleExpr, DictExpr, OpExpr)) and not ( |
6047 | | - self.in_lambda_expr or self.chk.current_node_deferred |
| 6033 | + elif ( |
| 6034 | + isinstance(node, (CallExpr, ListExpr, TupleExpr, DictExpr, OpExpr)) |
| 6035 | + and not (self.in_lambda_expr or self.chk.current_node_deferred) |
| 6036 | + and not self.chk.options.disable_expression_cache |
6048 | 6037 | ): |
6049 | 6038 | if (node, type_context) in self.expr_cache: |
6050 | 6039 | binder_version, typ, messages, type_map = self.expr_cache[(node, type_context)] |
|
0 commit comments