Decide if we should recurse into a module. This function caches its results and handles the logic to decide if a module should be included in the compilation or not. It respects the user choices, plugins, and standard library rules. Args: using_module_name: The module name
(
using_module_name, module_filename, module_name, module_kind, extra_recursion=False
)
| 157 | |
| 158 | |
| 159 | def decideRecursion( |
| 160 | using_module_name, module_filename, module_name, module_kind, extra_recursion=False |
| 161 | ): |
| 162 | """Decide if we should recurse into a module. |
| 163 | |
| 164 | This function caches its results and handles the logic to decide if a |
| 165 | module should be included in the compilation or not. It respects the |
| 166 | user choices, plugins, and standard library rules. |
| 167 | |
| 168 | Args: |
| 169 | using_module_name: The module name that triggers this recursion. |
| 170 | module_filename: The filename of the module. |
| 171 | module_name: The name of the module. |
| 172 | module_kind: The kind of the module. |
| 173 | extra_recursion: If true, this is a forced recursion (e.g. plugin). |
| 174 | |
| 175 | Returns: |
| 176 | A tuple (decision, reason) where decision is a boolean or None, and |
| 177 | reason is a string explaining the decision. |
| 178 | """ |
| 179 | package_part, _remainder = module_name.splitModuleBasename() |
| 180 | |
| 181 | if package_part is not None and package_part.getTopLevelPackageName() != "": |
| 182 | ( |
| 183 | _package_part, |
| 184 | package_filename, |
| 185 | package_module_kind, |
| 186 | package_finding, |
| 187 | ) = locateModule(module_name=package_part, parent_package=None, level=0) |
| 188 | assert _package_part == package_part, (_package_part, package_part) |
| 189 | |
| 190 | # For bad decisions, this may already not work. |
| 191 | if package_finding != "not-found": |
| 192 | package_decision, package_reason = decideRecursion( |
| 193 | using_module_name=using_module_name, |
| 194 | module_filename=package_filename, |
| 195 | module_name=package_part, |
| 196 | module_kind=package_module_kind, |
| 197 | extra_recursion=extra_recursion, |
| 198 | ) |
| 199 | |
| 200 | if package_decision is False: |
| 201 | return package_decision, package_reason |
| 202 | |
| 203 | key = using_module_name, module_filename, module_name, module_kind, extra_recursion |
| 204 | |
| 205 | if key not in _recursion_decision_cache: |
| 206 | _recursion_decision_cache[key] = _decideRecursion( |
| 207 | using_module_name, |
| 208 | module_filename, |
| 209 | module_name, |
| 210 | module_kind, |
| 211 | extra_recursion, |
| 212 | ) |
| 213 | |
| 214 | # If decided true, give the plugins a chance to e.g. add more hard |
| 215 | # module information, this indicates tentatively, that a module might |
| 216 | # get used, but it may also not happen at all. |
no test coverage detected
searching dependent graphs…