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()
})
}
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)
}