Path 1: 940 calls (0.87)

dict (652) {} (288)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 2: 52 calls (0.05)

dict (52)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 3: 44 calls (0.04)

dict (44)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 4: 12 calls (0.01)

dict (12)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 5: 9 calls (0.01)

dict (9)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 6: 4 calls (0.0)

dict (4)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 7: 2 calls (0.0)

dict (2)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 8: 2 calls (0.0)

dict (2)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 9: 2 calls (0.0)

dict (2)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 10: 2 calls (0.0)

dict (2)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 11: 2 calls (0.0)

dict (2)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 12: 2 calls (0.0)

dict (2)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 13: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 14: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 15: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 16: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 17: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 18: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 19: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 20: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 21: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 22: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 23: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 24: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume
            

Path 25: 1 calls (0.0)

dict (1)

1def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
2        local_names = _fix_dot_imports(not_consumed)
3        checked = set()
4        unused_wildcard_imports: defaultdict[
5            tuple[str, nodes.ImportFrom], list[str]
6        ] = collections.defaultdict(list)
7        for name, stmt in local_names:
8            for imports in stmt.names:
9                real_name = imported_name = imports[0]
10                if imported_name == "*":
11                    real_name = name
12                as_name = imports[1]
13                if real_name in checked:
14                    continue
15                if name not in (real_name, as_name):
16                    continue
17                checked.add(real_name)
18
19                is_type_annotation_import = (
20                    imported_name in self._type_annotation_names
21                    or as_name in self._type_annotation_names
22                )
23                if isinstance(stmt, nodes.Import) or (
24                    isinstance(stmt, nodes.ImportFrom) and not stmt.modname
25                ):
26                    if isinstance(stmt, nodes.ImportFrom) and SPECIAL_OBJ.search(
27                        imported_name
28                    ):
29                        # Filter special objects (__doc__, __all__) etc.,
30                        # because they can be imported for exporting.
31                        continue
32
33                    if is_type_annotation_import:
34                        # Most likely a typing import if it wasn't used so far.
35                        continue
36
37                    if as_name == "_":
38                        continue
39                    if as_name is None:
40                        msg = f"import {imported_name}"
41                    else:
42                        msg = f"{imported_name} imported as {as_name}"
43                    if not in_type_checking_block(stmt):
44                        self.add_message("unused-import", args=msg, node=stmt)
45                elif isinstance(stmt, nodes.ImportFrom) and stmt.modname != FUTURE:
46                    if SPECIAL_OBJ.search(imported_name):
47                        # Filter special objects (__doc__, __all__) etc.,
48                        # because they can be imported for exporting.
49                        continue
50
51                    if _is_from_future_import(stmt, name):
52                        # Check if the name is in fact loaded from a
53                        # __future__ import in another module.
54                        continue
55
56                    if is_type_annotation_import:
57                        # Most likely a typing import if it wasn't used so far.
58                        continue
59
60                    if imported_name == "*":
61                        unused_wildcard_imports[(stmt.modname, stmt)].append(name)
62                    else:
63                        if as_name is None:
64                            msg = f"{imported_name} imported from {stmt.modname}"
65                        else:
66                            msg = f"{imported_name} imported from {stmt.modname} as {as_name}"
67                        if not in_type_checking_block(stmt):
68                            self.add_message("unused-import", args=msg, node=stmt)
69
70        # Construct string for unused-wildcard-import message
71        for module, unused_list in unused_wildcard_imports.items():
72            if len(unused_list) == 1:
73                arg_string = unused_list[0]
74            else:
75                arg_string = (
76                    f"{', '.join(i for i in unused_list[:-1])} and {unused_list[-1]}"
77                )
78            self.add_message(
79                "unused-wildcard-import", args=(arg_string, module[0]), node=module[1]
80            )
81        del self._to_consume