From 4c57e6ead75b8dc05a094402ab99a0db2d663f4c Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Sat, 30 Nov 2024 11:36:38 +0900 Subject: [PATCH] fix: type decl generator --- crates/py2erg/gen_decl.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/py2erg/gen_decl.rs b/crates/py2erg/gen_decl.rs index 4d4211e..e85b926 100644 --- a/crates/py2erg/gen_decl.rs +++ b/crates/py2erg/gen_decl.rs @@ -63,6 +63,7 @@ impl DeclFileGenerator { fn escape_type(&self, typ: String) -> String { typ.replace('%', "Type_") .replace("", "") + .replace('/', ".") .trim_start_matches(self.filename.trim_end_matches(".d.er")) .trim_start_matches(&self.namespace) .to_string() @@ -70,7 +71,15 @@ impl DeclFileGenerator { // e.g. `x: foo.Bar` => `foo = pyimport "foo"; x: foo.Bar` fn prepare_using_type(&mut self, typ: &Type) { - let namespace = Str::rc(typ.namespace().split('.').next().unwrap()); + let namespace = Str::rc( + typ.namespace() + .split('/') + .next() + .unwrap() + .split('.') + .next() + .unwrap(), + ); if namespace != self.namespace && !namespace.is_empty() && self.imported.insert(namespace.clone())