impactsense-parser 0.1.1

Multi-language static analysis: parse codebases into an in-memory dependency graph for impact analysis
Documentation
//! Common third-party / optional top-level names (PyPI, Sphinx, etc.).
//! Imports whose first segment is listed here are not logged as unresolved when
//! they do not map to scanned files (same idea as stdlib filtering).
use std::collections::HashSet;
use std::sync::OnceLock;

fn external_top_level_names() -> &'static HashSet<String> {
    static SET: OnceLock<HashSet<String>> = OnceLock::new();
    SET.get_or_init(|| {
        include_str!("python_common_external_modules.txt")
            .lines()
            .map(|l| l.trim().to_string())
            .filter(|l| !l.is_empty() && !l.starts_with('#'))
            .collect()
    })
}

/// True if the first component of a dotted import is a known external package name.
pub fn is_python_common_external_top_level(import_dotted: &str) -> bool {
    let top = import_dotted
        .trim()
        .split('.')
        .next()
        .unwrap_or("")
        .trim();
    !top.is_empty() && external_top_level_names().contains(top)
}