|
216 | 216 | UnpackType, |
217 | 217 | find_unpack_in_list, |
218 | 218 | flatten_nested_unions, |
219 | | - flatten_nested_tuples, |
220 | 219 | get_proper_type, |
221 | 220 | get_proper_types, |
222 | 221 | is_literal_type, |
@@ -2937,7 +2936,7 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None: |
2937 | 2936 | isinstance(lvalue, NameExpr) |
2938 | 2937 | and isinstance(var := lvalue.node, Var) |
2939 | 2938 | ): |
2940 | | - self.search_deprecated(var.type, s) |
| 2939 | + self.search_deprecated(var.type, s, set()) |
2941 | 2940 |
|
2942 | 2941 | # Avoid type checking type aliases in stubs to avoid false |
2943 | 2942 | # positives about modern type syntax available in stubs such |
@@ -7581,17 +7580,17 @@ def warn_deprecated(self, node: SymbolNode | None, context: Context) -> None: |
7581 | 7580 | warn = self.msg.fail if self.options.report_deprecated_as_error else self.msg.note |
7582 | 7581 | warn(deprecated, context, code=codes.DEPRECATED) |
7583 | 7582 |
|
7584 | | - def search_deprecated(self, typ, s: AssignmentStmt) -> None: |
7585 | | - if isinstance(typ := get_proper_type(typ), Instance): |
7586 | | - self.check_deprecated(typ.type, s) |
7587 | | - for arg in typ.args: |
7588 | | - self.search_deprecated(arg, s) |
7589 | | - elif isinstance(typ, UnionType): |
7590 | | - for subtype in flatten_nested_unions([typ]): |
7591 | | - self.search_deprecated(subtype, s) |
7592 | | - elif isinstance(typ, TupleType): |
7593 | | - for subtype in flatten_types(typ): |
7594 | | - self.search_deprecated(subtype, s) |
| 7583 | + def search_deprecated(self, typ: Type | None, s: AssignmentStmt, visited: set[Type]) -> None: |
| 7584 | + |
| 7585 | + if typ not in visited: |
| 7586 | + visited.add(typ) |
| 7587 | + if isinstance(typ := get_proper_type(typ), Instance): |
| 7588 | + self.check_deprecated(typ.type, s) |
| 7589 | + for arg in typ.args: |
| 7590 | + self.search_deprecated(arg, s, visited) |
| 7591 | + elif isinstance(typ, (UnionType, TupleType)): |
| 7592 | + for item in typ.items: |
| 7593 | + self.search_deprecated(item, s, visited) |
7595 | 7594 |
|
7596 | 7595 |
|
7597 | 7596 | class CollectArgTypeVarTypes(TypeTraverserVisitor): |
|
0 commit comments