From e2d42bf8ea1d689c2d1400ed2b87e96e88d4ab5d Mon Sep 17 00:00:00 2001 From: Hung-I Wang Date: Thu, 22 Jun 2023 23:48:00 +0800 Subject: [PATCH] fix: `typing.Any` is not imported for `List[Any]` (close #3) --- src/target/python_class.rs | 5 ++++- src/target/python_inline.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/target/python_class.rs b/src/target/python_class.rs index a242022..b647d45 100644 --- a/src/target/python_class.rs +++ b/src/target/python_class.rs @@ -146,8 +146,11 @@ fn write_output( ); } } - Type::Array(_) => { + Type::Array(inner) => { imports_from_typing.insert("List"); + if schema.arena.get(inner).unwrap().is_any() { + imports_from_typing.insert("Any"); + } } _ => {} } diff --git a/src/target/python_inline.rs b/src/target/python_inline.rs index 02f91da..9219407 100644 --- a/src/target/python_inline.rs +++ b/src/target/python_inline.rs @@ -139,8 +139,11 @@ fn write_output( }); } } - Type::Array(_) => { + Type::Array(inner) => { imports_from_typing.insert("List"); + if schema.arena.get(inner).unwrap().is_any() { + imports_from_typing.insert("Any"); + } } _ => {} }