Path 1: 966 calls (0.81)

ImportFrom (546) Import (420)

'os' (73) 'typing' (43) 'sys' (41) 'collections' (24) '__future__.annotations' (22) 'typing.Union' (21) 'abc' (20) 're' (20) 'typing.List' (19) 'loggi...

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 2: 57 calls (0.05)

ImportFrom (36) Import (21)

'pytest' (7) 'typing_extensions' (6) 'input.func_w0401' (5) 'astroid.are_exclusive' (3) 'astroid' (3) 'input.func_w0401_package.thing1.THING1' (2) 'in...

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 3: 52 calls (0.04)

ImportFrom (50) Import (2)

'functional.i.foo' (3) 'functional.i.foo2' (3) 'pylint.run_pylint' (3) 'pylint.run_pyreverse' (3) 'pylint.run_symilar' (3) 'input.func_w0401_package.t...

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 4: 50 calls (0.04)

ImportFrom (47) Import (3)

'pylint.run_epylint' (3) 'pylint.lint.Run' (3) 'pylint.testutils.GenericTestReporter' (3) 'pylint.testutils.utils._test_cwd' (3) 'input.func_w0401_pac...

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 5: 42 calls (0.04)

ImportFrom (21) Import (21)

'os' (3) 'typing.Protocol' (3) 'sys' (2) 'collections.defaultdict' (2) 'typing.NoReturn' (2) 'collections.OrderedDict' (2) 'datetime' (2) 'types._Tree...

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 6: 10 calls (0.01)

ImportFrom (10)

'input.w0401_cycle' (4) 'a.c.foobar' (3) 'namespace_package.top_level_function' (1) 'namespace_package.plugin_api.top_message' (1) 'beyond_top_three.l...

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 7: 4 calls (0.0)

ImportFrom (4)

'private_import._private' (1) 'functional.i.import_itself' (1) 'functional.n.non.non_init_parent_called' (1) '__init__.subpackage' (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 8: 4 calls (0.0)

ImportFrom (4)

'typing_extensions.Protocol' (3) 'typing_extensions.Literal' (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 9: 3 calls (0.0)

ImportFrom (3)

'input.func_noerror_cycle.a.LstT' (2) 'typing_extensions.Literal' (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 10: 3 calls (0.0)

ImportFrom (2) Import (1)

'typing_extensions.NoReturn' (1) 'astroid.are_exclusive' (1) 'astroid' (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 11: 1 calls (0.0)

ImportFrom (1)

'six.moves.configparser' (1)

ImportError (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 12: 1 calls (0.0)

ImportFrom (1)

'functional.w.package4' (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)
            

Path 13: 1 calls (0.0)

ImportFrom (1)

'pylint.lint.PyLinter' (1)

1def _add_imported_module(self, node: ImportNode, importedmodname: str) -> None:
2        """Notify an imported module, used to analyze dependencies."""
3        module_file = node.root().file
4        context_name = node.root().name
5        base = os.path.splitext(os.path.basename(module_file))[0]
6
7        try:
8            importedmodname = astroid.modutils.get_module_part(
9                importedmodname, module_file
10            )
11        except ImportError:
12            pass
13
14        in_type_checking_block = isinstance(node.parent, nodes.If) and is_typing_guard(
15            node.parent
16        )
17
18        if context_name == importedmodname:
19            self.add_message("import-self", node=node)
20
21        elif not astroid.modutils.is_standard_module(importedmodname):
22            # if this is not a package __init__ module
23            if base != "__init__" and context_name not in self._module_pkg:
24                # record the module's parent, or the module itself if this is
25                # a top level module, as the package it belongs to
26                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]
27
28            # handle dependencies
29            dependencies_stat: dict[str, set[str]] = self.linter.stats.dependencies
30            importedmodnames = dependencies_stat.setdefault(importedmodname, set())
31            if context_name not in importedmodnames:
32                importedmodnames.add(context_name)
33
34            # update import graph
35            self.import_graph[context_name].add(importedmodname)
36            if (
37                not self.linter.is_message_enabled("cyclic-import", line=node.lineno)
38                or in_type_checking_block
39            ):
40                self._excluded_edges[context_name].add(importedmodname)