|
16 | 16 | import sys
|
17 | 17 | import token
|
18 | 18 | import tokenize
|
19 |
| -from typing import IO, Callable, Iterable, List, Tuple |
| 19 | +from typing import IO, Callable, Iterable, List, Set, Tuple |
20 | 20 |
|
21 | 21 | FILE_EXTENSIONS_TO_CHECK: Tuple[str, ...] = (".py", ".pyx", ".pxi.ini", ".pxd")
|
22 | 22 | PATHS_TO_IGNORE: Tuple[str, ...] = ("asv_bench/env",)
|
23 | 23 |
|
| 24 | +PRIVATE_IMPORTS_TO_IGNORE: Set[str] = { |
| 25 | + "_extension_array_shared_docs", |
| 26 | + "_index_shared_docs", |
| 27 | + "_merge_doc", |
| 28 | + "_shared_docs", |
| 29 | +} |
| 30 | + |
24 | 31 |
|
25 | 32 | def _get_literal_string_prefix_len(token_string: str) -> int:
|
26 | 33 | """
|
@@ -138,8 +145,13 @@ def private_function_across_module(file_obj: IO[str]) -> Iterable[Tuple[int, str
|
138 | 145 | if not (isinstance(node, ast.Import) or isinstance(node, ast.ImportFrom)):
|
139 | 146 | continue
|
140 | 147 |
|
141 |
| - if any(mod.name.split(".")[-1].startswith("_") for mod in node.names): |
142 |
| - yield (node.lineno, "Use of private function across modules found.") |
| 148 | + for module in node.names: |
| 149 | + module_name = module.name.split(".")[-1] |
| 150 | + if module_name in PRIVATE_IMPORTS_TO_IGNORE: |
| 151 | + continue |
| 152 | + |
| 153 | + if module_name.startswith("_"): |
| 154 | + yield (node.lineno, f"Import of internal function {repr(module_name)}") |
143 | 155 |
|
144 | 156 |
|
145 | 157 | def strings_to_concatenate(file_obj: IO[str]) -> Iterable[Tuple[int, str]]:
|
|
0 commit comments