Path 1: 652 calls (0.6)

dict (652)

[] (652)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 2: 288 calls (0.27)

{} (288)

[] (288)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 3: 75 calls (0.07)

dict (75)

list (75)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 4: 52 calls (0.05)

dict (52)

list (52)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 5: 9 calls (0.01)

dict (9)

list (9)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 6: 4 calls (0.0)

dict (4)

list (4)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 7: 3 calls (0.0)

dict (3)

list (3)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 8: 1 calls (0.0)

dict (1)

list (1)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 9: 1 calls (0.0)

dict (1)

list (1)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]
            

Path 10: 1 calls (0.0)

dict (1)

list (1)

1def _fix_dot_imports(
2    not_consumed: dict[str, list[nodes.NodeNG]]
3) -> list[tuple[str, _base_nodes.ImportNode]]:
4    """Try to fix imports with multiple dots, by returning a dictionary
5    with the import names expanded.
6
7    The function unflattens root imports,
8    like 'xml' (when we have both 'xml.etree' and 'xml.sax'), to 'xml.etree'
9    and 'xml.sax' respectively.
10    """
11    names: dict[str, _base_nodes.ImportNode] = {}
12    for name, stmts in not_consumed.items():
13        if any(
14            isinstance(stmt, nodes.AssignName)
15            and isinstance(stmt.assign_type(), nodes.AugAssign)
16            for stmt in stmts
17        ):
18            continue
19        for stmt in stmts:
20            if not isinstance(stmt, (nodes.ImportFrom, nodes.Import)):
21                continue
22            for imports in stmt.names:
23                second_name = None
24                import_module_name = imports[0]
25                if import_module_name == "*":
26                    # In case of wildcard imports,
27                    # pick the name from inside the imported module.
28                    second_name = name
29                else:
30                    name_matches_dotted_import = False
31                    if (
32                        import_module_name.startswith(name)
33                        and import_module_name.find(".") > -1
34                    ):
35                        name_matches_dotted_import = True
36
37                    if name_matches_dotted_import or name in imports:
38                        # Most likely something like 'xml.etree',
39                        # which will appear in the .locals as 'xml'.
40                        # Only pick the name if it wasn't consumed.
41                        second_name = import_module_name
42                if second_name and second_name not in names:
43                    names[second_name] = stmt
44    return sorted(names.items(), key=lambda a: a[1].fromlineno)  # type: ignore[no-any-return]