Merge branch 'main' into shape

This commit is contained in:
Shunsuke Shibayama 2023-08-02 18:43:43 +09:00
commit 278039c75b

View file

@ -2639,6 +2639,17 @@ impl Context {
} }
pub(crate) fn get_namespace_path(&self, namespace: &Str) -> Option<PathBuf> { pub(crate) fn get_namespace_path(&self, namespace: &Str) -> Option<PathBuf> {
// get the true name
let namespace = if let Some((_, vi)) = self.get_var_info(namespace) {
// m: PyModule("math") -> math
if vi.t.is_module() {
vi.t.typarams()[0].to_string().replace('"', "").into()
} else {
namespace.clone()
}
} else {
namespace.clone()
};
let mut namespaces = namespace.split_with(&[".", "::"]); let mut namespaces = namespace.split_with(&[".", "::"]);
let mut str_namespace = namespaces.first().map(|n| n.to_string())?; let mut str_namespace = namespaces.first().map(|n| n.to_string())?;
namespaces.remove(0); namespaces.remove(0);