Method: pylint.lint.expand_modules.expand_modules
Calls: 1064, Exceptions: 11, Paths: 16Back
Path 1: 973 calls (0.91)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/file_to_lint.py'] (50) ['/Users/andrehora/Documents/git/projects-pathspotter...
('CVS',) (963) ['CVS'] (6) ['test', 'test_two'] (1) ['migrations'] (1) [] (1) ['foo', 'bar', 'bin'] (1)
tuple (966) list (6) [] (1)
[] (972) list (1)
tuple (973)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 2: 22 calls (0.02)
['test_directory'] (2) ['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/checkers/../regrtest_data/allow_reexport'] (2) ['/Users/andr...
('CVS',) (18) ['CVS'] (3) [] (1)
tuple (18) list (3) [] (1)
[] (22)
tuple (22)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 3: 16 calls (0.02)
['input.func_i0013'] (1) ['input.func_w0401_disabled', 'input.w0401_cycle'] (1) ['input.func_w0801', 'input.w0801_same'] (1) ['input.func_w0401', 'inp...
('CVS',) (15) ['CVS'] (1)
tuple (15) list (1)
[] (16)
tuple (16)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 4: 10 calls (0.01)
('/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/directory/subdirectory/module.py', '/Users/andrehora/Document...
('CVS',) (7) ['failing.py'] (3)
tuple (7) list (3)
[] (6) list (4)
tuple (10)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 5: 9 calls (0.01)
('/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/directory/subdirectory/module.py', '/Users/andrehora/Document...
('CVS',) (6) ['ignored_subdirectory'] (3)
tuple (6) list (3)
[] (6) list (3)
tuple (9)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 6: 5 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/input/similar1'] (1) ['/Users/andrehora/Documents/git/projects-pathspotter/pylint/t...
('CVS',) (5)
tuple (4) list (1)
[] (5)
tuple (5)
ImportError (5)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 7: 5 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/data'] (2) ['not_here', 'not_here_too'] (1) ['/Users/andrehora/Documents/git/p...
('CVS',) (5)
tuple (5)
[] (5)
tuple (5)
ImportError (5)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 8: 4 calls (0.0)
['input.func_w0401_package', 'input.w0401_cycle'] (1) ['input.func_noerror_cycle'] (1) ['input'] (1) ['outer.namespace'] (1)
('CVS',) (4)
tuple (4)
[] (4)
tuple (4)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 9: 4 calls (0.0)
['package.__init__'] (2) ['pylint.checkers.__init__'] (1) ['__init__'] (1)
('CVS',) (4)
tuple (4)
[] (4)
tuple (4)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 10: 4 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/regrtest_data/regression_missing_init_3564/subdirectory/'] (1) ['/Users/andrehora/D...
('CVS',) (2) ['CVS'] (2)
tuple (2) list (2)
[] (4)
tuple (4)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 11: 3 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/e/.#emacs_file_lock.py'] (1) ['/Users/andrehora/Documents/git/projects-p...
('CVS',) (2) [] (1)
tuple (1) list (1) [] (1)
[] (2) list (1)
tuple (3)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 12: 3 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/functional/t/too/too_many_branches.py', '/Users/andrehora/Documents/git/projects-pa...
('CVS',) (2) [] (1)
tuple (2) [] (1)
[] (3)
tuple (3)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 13: 3 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint/../regrtest_data/bad_package', '/Users/andrehora/Documents/git/projects-pathsp...
('CVS',) (2) [] (1)
tuple (2) [] (1)
[] (3)
tuple (3)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 14: 1 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/regrtest_data/hang/pkg4972.string'] (1)
('CVS',) (1)
tuple (1)
[] (1)
tuple (1)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 15: 1 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/conftest.py', '/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/gar...
('CVS',) (1)
tuple (1)
[] (1)
tuple (1)
ImportError (1)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors
Path 16: 1 calls (0.0)
['/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/lint'] (1)
[] (1)
[] (1)
list (1)
tuple (1)
1def expand_modules(
2 files_or_modules: Sequence[str],
3 ignore_list: list[str],
4 ignore_list_re: list[Pattern[str]],
5 ignore_list_paths_re: list[Pattern[str]],
6) -> tuple[dict[str, ModuleDescriptionDict], list[ErrorDescriptionDict]]:
7 """Take a list of files/modules/packages and return the list of tuple
8 (file, module name) which have to be actually checked.
9 """
10 result: dict[str, ModuleDescriptionDict] = {}
11 errors: list[ErrorDescriptionDict] = []
12 path = sys.path.copy()
13
14 for something in files_or_modules:
15 basename = os.path.basename(something)
16 if _is_ignored_file(
17 something, ignore_list, ignore_list_re, ignore_list_paths_re
18 ):
19 continue
20 module_path = get_python_path(something)
21 additional_search_path = [".", module_path] + path
22 if os.path.exists(something):
23 # this is a file or a directory
24 try:
25 modname = ".".join(
26 modutils.modpath_from_file(something, path=additional_search_path)
27 )
28 except ImportError:
29 modname = os.path.splitext(basename)[0]
30 if os.path.isdir(something):
31 filepath = os.path.join(something, "__init__.py")
32 else:
33 filepath = something
34 else:
35 # suppose it's a module or package
36 modname = something
37 try:
38 filepath = modutils.file_from_modpath(
39 modname.split("."), path=additional_search_path
40 )
41 if filepath is None:
42 continue
43 except ImportError as ex:
44 errors.append({"key": "fatal", "mod": modname, "ex": ex})
45 continue
46 filepath = os.path.normpath(filepath)
47 modparts = (modname or something).split(".")
48 try:
49 spec = modutils.file_info_from_modpath(
50 modparts, path=additional_search_path
51 )
52 except ImportError:
53 # Might not be acceptable, don't crash.
54 is_namespace = False
55 is_directory = os.path.isdir(something)
56 else:
57 is_namespace = modutils.is_namespace(spec)
58 is_directory = modutils.is_directory(spec)
59 if not is_namespace:
60 if filepath in result:
61 # Always set arg flag if module explicitly given.
62 result[filepath]["isarg"] = True
63 else:
64 result[filepath] = {
65 "path": filepath,
66 "name": modname,
67 "isarg": True,
68 "basepath": filepath,
69 "basename": modname,
70 }
71 has_init = (
72 not (modname.endswith(".__init__") or modname == "__init__")
73 and os.path.basename(filepath) == "__init__.py"
74 )
75 if has_init or is_namespace or is_directory:
76 for subfilepath in modutils.get_module_files(
77 os.path.dirname(filepath), ignore_list, list_all=is_namespace
78 ):
79 if filepath == subfilepath:
80 continue
81 if _is_in_ignore_list_re(
82 os.path.basename(subfilepath), ignore_list_re
83 ) or _is_in_ignore_list_re(subfilepath, ignore_list_paths_re):
84 continue
85
86 modpath = _modpath_from_file(
87 subfilepath, is_namespace, path=additional_search_path
88 )
89 submodname = ".".join(modpath)
90 # Preserve arg flag if module is also explicitly given.
91 isarg = subfilepath in result and result[subfilepath]["isarg"]
92 result[subfilepath] = {
93 "path": subfilepath,
94 "name": submodname,
95 "isarg": isarg,
96 "basepath": filepath,
97 "basename": modname,
98 }
99 return result, errors