Method: pylint.checkers.variables.VariablesChecker.visit_const
Calls: 12000, Exceptions: 3, Paths: 9Back
Path 1: 8721 calls (0.73)
Const (8721)
None (8721)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 2: 3225 calls (0.27)
Const (3225)
None (3225)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 3: 19 calls (0.0)
Const (19)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 4: 17 calls (0.0)
Const (17)
None (17)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 5: 7 calls (0.0)
Const (7)
None (7)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 6: 5 calls (0.0)
Const (5)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 7: 3 calls (0.0)
Const (3)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 8: 2 calls (0.0)
Const (2)
ValueError (2)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass
Path 9: 1 calls (0.0)
Const (1)
AstroidSyntaxError (1)
1@utils.only_required_for_messages(
2 "unused-import",
3 "unused-variable",
4 )
5 def visit_const(self, node: nodes.Const) -> None:
6 """Take note of names that appear inside string literal type annotations
7 unless the string is a parameter to `typing.Literal` or `typing.Annotation`.
8 """
9 if node.pytype() != "builtins.str":
10 return
11 if not utils.is_node_in_type_annotation_context(node):
12 return
13
14 # Check if parent's or grandparent's first child is typing.Literal
15 parent = node.parent
16 if isinstance(parent, nodes.Tuple):
17 parent = parent.parent
18 if isinstance(parent, nodes.Subscript):
19 origin = next(parent.get_children(), None)
20 if origin is not None and utils.is_typing_member(
21 origin, ("Annotated", "Literal")
22 ):
23 return
24
25 try:
26 annotation = extract_node(node.value)
27 self._store_type_annotation_node(annotation)
28 except ValueError:
29 # e.g. node.value is white space
30 pass
31 except astroid.AstroidSyntaxError:
32 # e.g. "?" or ":" in typing.Literal["?", ":"]
33 pass