Return a copy of the __all__ dict with irrelevant items removed. Parameters ---------- module : ModuleType The module whose __all__ dict has to be processed Returns ------- deprecated : list List of callable and deprecated sub modules not_deprecated
(module)
| 188 | |
| 189 | |
| 190 | def get_all_dict(module): |
| 191 | """ |
| 192 | Return a copy of the __all__ dict with irrelevant items removed. |
| 193 | |
| 194 | Parameters |
| 195 | ---------- |
| 196 | module : ModuleType |
| 197 | The module whose __all__ dict has to be processed |
| 198 | |
| 199 | Returns |
| 200 | ------- |
| 201 | deprecated : list |
| 202 | List of callable and deprecated sub modules |
| 203 | not_deprecated : list |
| 204 | List of non callable or non deprecated sub modules |
| 205 | others : list |
| 206 | List of remaining types of sub modules |
| 207 | """ |
| 208 | if hasattr(module, "__all__"): |
| 209 | all_dict = copy.deepcopy(module.__all__) |
| 210 | else: |
| 211 | all_dict = copy.deepcopy(dir(module)) |
| 212 | all_dict = [name for name in all_dict |
| 213 | if not name.startswith("_")] |
| 214 | for name in ['absolute_import', 'division', 'print_function']: |
| 215 | try: |
| 216 | all_dict.remove(name) |
| 217 | except ValueError: |
| 218 | pass |
| 219 | if not all_dict: |
| 220 | # Must be a pure documentation module |
| 221 | all_dict.append('__doc__') |
| 222 | |
| 223 | # Modules are almost always private; real submodules need a separate |
| 224 | # run of refguide_check. |
| 225 | all_dict = [name for name in all_dict |
| 226 | if not inspect.ismodule(getattr(module, name, None))] |
| 227 | |
| 228 | deprecated = [] |
| 229 | not_deprecated = [] |
| 230 | for name in all_dict: |
| 231 | f = getattr(module, name, None) |
| 232 | if callable(f) and is_deprecated(f): |
| 233 | deprecated.append(name) |
| 234 | else: |
| 235 | not_deprecated.append(name) |
| 236 | |
| 237 | others = set(dir(module)).difference(set(deprecated)).difference(set(not_deprecated)) # noqa: E501 |
| 238 | |
| 239 | return not_deprecated, deprecated, others |
| 240 | |
| 241 | |
| 242 | def compare(all_dict, others, names, module_name): |
no test coverage detected
searching dependent graphs…