Path 1: 487 calls (0.52)

AssignName (487)

'Final' (487)

False (487)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 2: 150 calls (0.16)

AssignName (150)

'Final' (150)

False (150)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 3: 120 calls (0.13)

AssignName (120)

'Final' (120)

False (120)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 4: 75 calls (0.08)

AssignName (75)

'Final' (75)

False (75)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 5: 54 calls (0.06)

AssignName (54)

'Final' (54)

False (54)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 6: 27 calls (0.03)

AssignName (27)

'Final' (27)

False (27)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 7: 6 calls (0.01)

AssignName (6)

'Final' (6)

True (6)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 8: 5 calls (0.01)

AssignName (5)

'Final' (5)

True (5)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 9: 4 calls (0.0)

AssignName (4)

'Final' (4)

True (4)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False
            

Path 10: 2 calls (0.0)

AssignName (2)

'Final' (2)

True (2)

1def is_assign_name_annotated_with(node: nodes.AssignName, typing_name: str) -> bool:
2    """Test if AssignName node has `typing_name` annotation.
3
4    Especially useful to check for `typing._SpecialForm` instances
5    like: `Union`, `Optional`, `Literal`, `ClassVar`, `Final`.
6    """
7    if not isinstance(node.parent, nodes.AnnAssign):
8        return False
9    annotation = node.parent.annotation
10    if isinstance(annotation, nodes.Subscript):
11        annotation = annotation.value
12    if (
13        isinstance(annotation, nodes.Name)
14        and annotation.name == typing_name
15        or isinstance(annotation, nodes.Attribute)
16        and annotation.attrname == typing_name
17    ):
18        return True
19    return False