Path 1: 749 calls (0.94)

None (731) [] (18)

[] (749)

1def uninferable_final_decorators(
2    node: nodes.Decorators,
3) -> list[nodes.Attribute | nodes.Name | None]:
4    """Return a list of uninferable `typing.final` decorators in `node`.
5
6    This function is used to determine if the `typing.final` decorator is used
7    with an unsupported Python version; the decorator cannot be inferred when
8    using a Python version lower than 3.8.
9    """
10    decorators = []
11    for decorator in getattr(node, "nodes", []):
12        import_nodes: tuple[nodes.Import | nodes.ImportFrom] | None = None
13
14        # Get the `Import` node. The decorator is of the form: @module.name
15        if isinstance(decorator, nodes.Attribute):
16            inferred = safe_infer(decorator.expr)
17            if isinstance(inferred, nodes.Module) and inferred.qname() == "typing":
18                _, import_nodes = decorator.expr.lookup(decorator.expr.name)
19
20        # Get the `ImportFrom` node. The decorator is of the form: @name
21        elif isinstance(decorator, nodes.Name):
22            _, import_nodes = decorator.lookup(decorator.name)
23
24        # The `final` decorator is expected to be found in the
25        # import_nodes. Continue if we don't find any `Import` or `ImportFrom`
26        # nodes for this decorator.
27        if not import_nodes:
28            continue
29        import_node = import_nodes[0]
30
31        if not isinstance(import_node, (astroid.Import, astroid.ImportFrom)):
32            continue
33
34        import_names = dict(import_node.names)
35
36        # Check if the import is of the form: `from typing import final`
37        is_from_import = ("final" in import_names) and import_node.modname == "typing"
38
39        # Check if the import is of the form: `import typing`
40        is_import = ("typing" in import_names) and getattr(
41            decorator, "attrname", None
42        ) == "final"
43
44        if (is_from_import or is_import) and safe_infer(decorator) in [
45            astroid.Uninferable,
46            None,
47        ]:
48            decorators.append(decorator)
49    return decorators
            

Path 2: 22 calls (0.03)

Decorators (22)

[] (22)

1def uninferable_final_decorators(
2    node: nodes.Decorators,
3) -> list[nodes.Attribute | nodes.Name | None]:
4    """Return a list of uninferable `typing.final` decorators in `node`.
5
6    This function is used to determine if the `typing.final` decorator is used
7    with an unsupported Python version; the decorator cannot be inferred when
8    using a Python version lower than 3.8.
9    """
10    decorators = []
11    for decorator in getattr(node, "nodes", []):
12        import_nodes: tuple[nodes.Import | nodes.ImportFrom] | None = None
13
14        # Get the `Import` node. The decorator is of the form: @module.name
15        if isinstance(decorator, nodes.Attribute):
16            inferred = safe_infer(decorator.expr)
17            if isinstance(inferred, nodes.Module) and inferred.qname() == "typing":
18                _, import_nodes = decorator.expr.lookup(decorator.expr.name)
19
20        # Get the `ImportFrom` node. The decorator is of the form: @name
21        elif isinstance(decorator, nodes.Name):
22            _, import_nodes = decorator.lookup(decorator.name)
23
24        # The `final` decorator is expected to be found in the
25        # import_nodes. Continue if we don't find any `Import` or `ImportFrom`
26        # nodes for this decorator.
27        if not import_nodes:
28            continue
29        import_node = import_nodes[0]
30
31        if not isinstance(import_node, (astroid.Import, astroid.ImportFrom)):
32            continue
33
34        import_names = dict(import_node.names)
35
36        # Check if the import is of the form: `from typing import final`
37        is_from_import = ("final" in import_names) and import_node.modname == "typing"
38
39        # Check if the import is of the form: `import typing`
40        is_import = ("typing" in import_names) and getattr(
41            decorator, "attrname", None
42        ) == "final"
43
44        if (is_from_import or is_import) and safe_infer(decorator) in [
45            astroid.Uninferable,
46            None,
47        ]:
48            decorators.append(decorator)
49    return decorators
            

Path 3: 13 calls (0.02)

Decorators (13)

[] (13)

1def uninferable_final_decorators(
2    node: nodes.Decorators,
3) -> list[nodes.Attribute | nodes.Name | None]:
4    """Return a list of uninferable `typing.final` decorators in `node`.
5
6    This function is used to determine if the `typing.final` decorator is used
7    with an unsupported Python version; the decorator cannot be inferred when
8    using a Python version lower than 3.8.
9    """
10    decorators = []
11    for decorator in getattr(node, "nodes", []):
12        import_nodes: tuple[nodes.Import | nodes.ImportFrom] | None = None
13
14        # Get the `Import` node. The decorator is of the form: @module.name
15        if isinstance(decorator, nodes.Attribute):
16            inferred = safe_infer(decorator.expr)
17            if isinstance(inferred, nodes.Module) and inferred.qname() == "typing":
18                _, import_nodes = decorator.expr.lookup(decorator.expr.name)
19
20        # Get the `ImportFrom` node. The decorator is of the form: @name
21        elif isinstance(decorator, nodes.Name):
22            _, import_nodes = decorator.lookup(decorator.name)
23
24        # The `final` decorator is expected to be found in the
25        # import_nodes. Continue if we don't find any `Import` or `ImportFrom`
26        # nodes for this decorator.
27        if not import_nodes:
28            continue
29        import_node = import_nodes[0]
30
31        if not isinstance(import_node, (astroid.Import, astroid.ImportFrom)):
32            continue
33
34        import_names = dict(import_node.names)
35
36        # Check if the import is of the form: `from typing import final`
37        is_from_import = ("final" in import_names) and import_node.modname == "typing"
38
39        # Check if the import is of the form: `import typing`
40        is_import = ("typing" in import_names) and getattr(
41            decorator, "attrname", None
42        ) == "final"
43
44        if (is_from_import or is_import) and safe_infer(decorator) in [
45            astroid.Uninferable,
46            None,
47        ]:
48            decorators.append(decorator)
49    return decorators
            

Path 4: 10 calls (0.01)

Decorators (10)

[] (10)

1def uninferable_final_decorators(
2    node: nodes.Decorators,
3) -> list[nodes.Attribute | nodes.Name | None]:
4    """Return a list of uninferable `typing.final` decorators in `node`.
5
6    This function is used to determine if the `typing.final` decorator is used
7    with an unsupported Python version; the decorator cannot be inferred when
8    using a Python version lower than 3.8.
9    """
10    decorators = []
11    for decorator in getattr(node, "nodes", []):
12        import_nodes: tuple[nodes.Import | nodes.ImportFrom] | None = None
13
14        # Get the `Import` node. The decorator is of the form: @module.name
15        if isinstance(decorator, nodes.Attribute):
16            inferred = safe_infer(decorator.expr)
17            if isinstance(inferred, nodes.Module) and inferred.qname() == "typing":
18                _, import_nodes = decorator.expr.lookup(decorator.expr.name)
19
20        # Get the `ImportFrom` node. The decorator is of the form: @name
21        elif isinstance(decorator, nodes.Name):
22            _, import_nodes = decorator.lookup(decorator.name)
23
24        # The `final` decorator is expected to be found in the
25        # import_nodes. Continue if we don't find any `Import` or `ImportFrom`
26        # nodes for this decorator.
27        if not import_nodes:
28            continue
29        import_node = import_nodes[0]
30
31        if not isinstance(import_node, (astroid.Import, astroid.ImportFrom)):
32            continue
33
34        import_names = dict(import_node.names)
35
36        # Check if the import is of the form: `from typing import final`
37        is_from_import = ("final" in import_names) and import_node.modname == "typing"
38
39        # Check if the import is of the form: `import typing`
40        is_import = ("typing" in import_names) and getattr(
41            decorator, "attrname", None
42        ) == "final"
43
44        if (is_from_import or is_import) and safe_infer(decorator) in [
45            astroid.Uninferable,
46            None,
47        ]:
48            decorators.append(decorator)
49    return decorators
            

Path 5: 5 calls (0.01)

Decorators (5)

[] (5)

1def uninferable_final_decorators(
2    node: nodes.Decorators,
3) -> list[nodes.Attribute | nodes.Name | None]:
4    """Return a list of uninferable `typing.final` decorators in `node`.
5
6    This function is used to determine if the `typing.final` decorator is used
7    with an unsupported Python version; the decorator cannot be inferred when
8    using a Python version lower than 3.8.
9    """
10    decorators = []
11    for decorator in getattr(node, "nodes", []):
12        import_nodes: tuple[nodes.Import | nodes.ImportFrom] | None = None
13
14        # Get the `Import` node. The decorator is of the form: @module.name
15        if isinstance(decorator, nodes.Attribute):
16            inferred = safe_infer(decorator.expr)
17            if isinstance(inferred, nodes.Module) and inferred.qname() == "typing":
18                _, import_nodes = decorator.expr.lookup(decorator.expr.name)
19
20        # Get the `ImportFrom` node. The decorator is of the form: @name
21        elif isinstance(decorator, nodes.Name):
22            _, import_nodes = decorator.lookup(decorator.name)
23
24        # The `final` decorator is expected to be found in the
25        # import_nodes. Continue if we don't find any `Import` or `ImportFrom`
26        # nodes for this decorator.
27        if not import_nodes:
28            continue
29        import_node = import_nodes[0]
30
31        if not isinstance(import_node, (astroid.Import, astroid.ImportFrom)):
32            continue
33
34        import_names = dict(import_node.names)
35
36        # Check if the import is of the form: `from typing import final`
37        is_from_import = ("final" in import_names) and import_node.modname == "typing"
38
39        # Check if the import is of the form: `import typing`
40        is_import = ("typing" in import_names) and getattr(
41            decorator, "attrname", None
42        ) == "final"
43
44        if (is_from_import or is_import) and safe_infer(decorator) in [
45            astroid.Uninferable,
46            None,
47        ]:
48            decorators.append(decorator)
49    return decorators
            

Path 6: 2 calls (0.0)

Decorators (2)

[] (2)

1def uninferable_final_decorators(
2    node: nodes.Decorators,
3) -> list[nodes.Attribute | nodes.Name | None]:
4    """Return a list of uninferable `typing.final` decorators in `node`.
5
6    This function is used to determine if the `typing.final` decorator is used
7    with an unsupported Python version; the decorator cannot be inferred when
8    using a Python version lower than 3.8.
9    """
10    decorators = []
11    for decorator in getattr(node, "nodes", []):
12        import_nodes: tuple[nodes.Import | nodes.ImportFrom] | None = None
13
14        # Get the `Import` node. The decorator is of the form: @module.name
15        if isinstance(decorator, nodes.Attribute):
16            inferred = safe_infer(decorator.expr)
17            if isinstance(inferred, nodes.Module) and inferred.qname() == "typing":
18                _, import_nodes = decorator.expr.lookup(decorator.expr.name)
19
20        # Get the `ImportFrom` node. The decorator is of the form: @name
21        elif isinstance(decorator, nodes.Name):
22            _, import_nodes = decorator.lookup(decorator.name)
23
24        # The `final` decorator is expected to be found in the
25        # import_nodes. Continue if we don't find any `Import` or `ImportFrom`
26        # nodes for this decorator.
27        if not import_nodes:
28            continue
29        import_node = import_nodes[0]
30
31        if not isinstance(import_node, (astroid.Import, astroid.ImportFrom)):
32            continue
33
34        import_names = dict(import_node.names)
35
36        # Check if the import is of the form: `from typing import final`
37        is_from_import = ("final" in import_names) and import_node.modname == "typing"
38
39        # Check if the import is of the form: `import typing`
40        is_import = ("typing" in import_names) and getattr(
41            decorator, "attrname", None
42        ) == "final"
43
44        if (is_from_import or is_import) and safe_infer(decorator) in [
45            astroid.Uninferable,
46            None,
47        ]:
48            decorators.append(decorator)
49    return decorators