(self, i: Import)
| 2927 | # |
| 2928 | |
| 2929 | def visit_import(self, i: Import) -> None: |
| 2930 | self.statement = i |
| 2931 | for id, as_id in i.ids: |
| 2932 | # Modules imported in a stub file without using 'import X as X' won't get exported |
| 2933 | # When implicit re-exporting is disabled, we have the same behavior as stubs. |
| 2934 | use_implicit_reexport = not self.is_stub_file and self.options.implicit_reexport |
| 2935 | if as_id is not None: |
| 2936 | base_id = id |
| 2937 | imported_id = as_id |
| 2938 | module_public = use_implicit_reexport or id == as_id |
| 2939 | else: |
| 2940 | base_id = id.split(".")[0] |
| 2941 | imported_id = base_id |
| 2942 | module_public = use_implicit_reexport |
| 2943 | |
| 2944 | if base_id in self.modules: |
| 2945 | node = self.modules[base_id] |
| 2946 | if self.is_func_scope(): |
| 2947 | kind = LDEF |
| 2948 | elif self.type is not None: |
| 2949 | kind = MDEF |
| 2950 | else: |
| 2951 | kind = GDEF |
| 2952 | symbol = SymbolTableNode( |
| 2953 | kind, node, module_public=module_public, module_hidden=not module_public |
| 2954 | ) |
| 2955 | self.add_imported_symbol( |
| 2956 | imported_id, |
| 2957 | symbol, |
| 2958 | context=i, |
| 2959 | module_public=module_public, |
| 2960 | module_hidden=not module_public, |
| 2961 | ) |
| 2962 | else: |
| 2963 | self.add_unknown_imported_symbol( |
| 2964 | imported_id, |
| 2965 | context=i, |
| 2966 | target_name=base_id, |
| 2967 | module_public=module_public, |
| 2968 | module_hidden=not module_public, |
| 2969 | ) |
| 2970 | |
| 2971 | def visit_import_from(self, imp: ImportFrom) -> None: |
| 2972 | self.statement = imp |
nothing calls this directly
no test coverage detected