Method: pylint.extensions.typing.TypingChecker.visit_annassign
Calls: 121, Exceptions: 0, Paths: 5Back
Path 1: 82 calls (0.68)
AnnAssign (82)
None (82)
1@only_required_for_messages("redundant-typehint-argument")
2 def visit_annassign(self, node: nodes.AnnAssign) -> None:
3 annotation = node.annotation
4 if self._is_deprecated_union_annotation(annotation, "Optional"):
5 if self._is_optional_none_annotation(annotation):
6 self.add_message(
7 "redundant-typehint-argument",
8 node=annotation,
9 args="None",
10 confidence=HIGH,
11 )
12 return
13 if self._is_deprecated_union_annotation(annotation, "Union") and isinstance(
14 annotation.slice, nodes.Tuple
15 ):
16 types = annotation.slice.elts
17 elif self._is_binop_union_annotation(annotation):
18 types = self._parse_binops_typehints(annotation)
19 else:
20 return
21
22 self._check_union_types(types, node)
Path 2: 14 calls (0.12)
AnnAssign (14)
1@only_required_for_messages("redundant-typehint-argument")
2 def visit_annassign(self, node: nodes.AnnAssign) -> None:
3 annotation = node.annotation
4 if self._is_deprecated_union_annotation(annotation, "Optional"):
5 if self._is_optional_none_annotation(annotation):
6 self.add_message(
7 "redundant-typehint-argument",
8 node=annotation,
9 args="None",
10 confidence=HIGH,
11 )
12 return
13 if self._is_deprecated_union_annotation(annotation, "Union") and isinstance(
14 annotation.slice, nodes.Tuple
15 ):
16 types = annotation.slice.elts
17 elif self._is_binop_union_annotation(annotation):
18 types = self._parse_binops_typehints(annotation)
19 else:
20 return
21
22 self._check_union_types(types, node)
Path 3: 13 calls (0.11)
AnnAssign (13)
1@only_required_for_messages("redundant-typehint-argument")
2 def visit_annassign(self, node: nodes.AnnAssign) -> None:
3 annotation = node.annotation
4 if self._is_deprecated_union_annotation(annotation, "Optional"):
5 if self._is_optional_none_annotation(annotation):
6 self.add_message(
7 "redundant-typehint-argument",
8 node=annotation,
9 args="None",
10 confidence=HIGH,
11 )
12 return
13 if self._is_deprecated_union_annotation(annotation, "Union") and isinstance(
14 annotation.slice, nodes.Tuple
15 ):
16 types = annotation.slice.elts
17 elif self._is_binop_union_annotation(annotation):
18 types = self._parse_binops_typehints(annotation)
19 else:
20 return
21
22 self._check_union_types(types, node)
Path 4: 10 calls (0.08)
AnnAssign (10)
None (10)
1@only_required_for_messages("redundant-typehint-argument")
2 def visit_annassign(self, node: nodes.AnnAssign) -> None:
3 annotation = node.annotation
4 if self._is_deprecated_union_annotation(annotation, "Optional"):
5 if self._is_optional_none_annotation(annotation):
6 self.add_message(
7 "redundant-typehint-argument",
8 node=annotation,
9 args="None",
10 confidence=HIGH,
11 )
12 return
13 if self._is_deprecated_union_annotation(annotation, "Union") and isinstance(
14 annotation.slice, nodes.Tuple
15 ):
16 types = annotation.slice.elts
17 elif self._is_binop_union_annotation(annotation):
18 types = self._parse_binops_typehints(annotation)
19 else:
20 return
21
22 self._check_union_types(types, node)
Path 5: 2 calls (0.02)
AnnAssign (2)
None (2)
1@only_required_for_messages("redundant-typehint-argument")
2 def visit_annassign(self, node: nodes.AnnAssign) -> None:
3 annotation = node.annotation
4 if self._is_deprecated_union_annotation(annotation, "Optional"):
5 if self._is_optional_none_annotation(annotation):
6 self.add_message(
7 "redundant-typehint-argument",
8 node=annotation,
9 args="None",
10 confidence=HIGH,
11 )
12 return
13 if self._is_deprecated_union_annotation(annotation, "Union") and isinstance(
14 annotation.slice, nodes.Tuple
15 ):
16 types = annotation.slice.elts
17 elif self._is_binop_union_annotation(annotation):
18 types = self._parse_binops_typehints(annotation)
19 else:
20 return
21
22 self._check_union_types(types, node)