Method: pylint.checkers.utils.get_subscript_const_value
Calls: 30, Exceptions: 0, Paths: 1Back
Path 1: 30 calls (1.0)
Subscript (30)
Const (30)
1def get_subscript_const_value(node: nodes.Subscript) -> nodes.Const:
2 """Returns the value 'subscript.slice' of a Subscript node.
3
4 :param node: Subscript Node to extract value from
5 :returns: Const Node containing subscript value
6 :raises InferredTypeError: if the subscript node cannot be inferred as a Const
7 """
8 inferred = safe_infer(node.slice)
9 if not isinstance(inferred, nodes.Const):
10 raise InferredTypeError("Subscript.slice cannot be inferred as a nodes.Const")
11
12 return inferred