176176
177177_COMMENT_PREFIXES = ("#" , "//" , "*" , "/*" , "--" , '"""' , "'''" , "<!--" )
178178
179- _EXTERNAL_IMPORT_RE = re .compile (
180- r"""(?:import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]|from\s+(\S+)\s+import\s+(.+))""" ,
181- )
179+ _JS_IMPORT_RE = re .compile (r"""import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]""" )
180+ _PY_IMPORT_RE = re .compile (r"""from\s+(\S+)\s+import\s+(.+)""" )
182181
183182
184183def _parse_import_names (names_str : str ) -> set [str ]:
@@ -193,12 +192,13 @@ def _parse_import_names(names_str: str) -> set[str]:
193192def _collect_external_symbols (diff_text : str ) -> frozenset [str ]:
194193 symbols : set [str ] = set ()
195194 for line in _extract_changed_lines (diff_text ):
196- for m in _EXTERNAL_IMPORT_RE .finditer (line ):
195+ for m in _JS_IMPORT_RE .finditer (line ):
197196 js_names , js_source = m .group (1 ), m .group (2 )
198- py_module , py_names = m .group (3 ), m .group (4 )
199- if js_names and js_source and not js_source .startswith ("." ):
197+ if not js_source .startswith ("." ):
200198 symbols .update (_parse_import_names (js_names ))
201- if py_module and py_names and not py_module .startswith ("." ):
199+ for m in _PY_IMPORT_RE .finditer (line ):
200+ py_module , py_names = m .group (1 ), m .group (2 )
201+ if not py_module .startswith ("." ):
202202 symbols .update (_parse_import_names (py_names ))
203203 return frozenset (symbols )
204204
0 commit comments