Extract normalize_from_import_string into _parse_utils.py
The from-import normalization block (clean up import(, backslash
continuations, newlines; split on ' import '/' cimport '; reconstruct
the canonical from X import Y, Z form) was copy-pasted almost identically
in both parse.py and identify.py.
Introduce normalize_from_import_string(import_string, cimports=None)
in _parse_utils.py. When cimports is None (parse.py path) the function
auto-detects it from the normalized string; when the caller already knows
the value (identify.py path) it can pass it explicitly.
Both parse.py and identify.py are updated to use the new helper,
removing ~15 lines of duplicated code.
Co-authored-by:
DanielNoord <13665637+DanielNoord@users.noreply.github.com>
Loading
Please register or sign in to comment