Handle typing collisions and add validation to a files module for overlaping declarations (#582)
* Fix 'typing' import collisions. * Fix formatting. * Fix self-test issues. * Validation for modules, different typing configurations * add readme * make warning * fix format --------- Co-authored-by: Scott Hendricks <scott.hendricks@confluent.io>
This commit is contained in:
@@ -47,6 +47,7 @@ def get_type_reference(
|
||||
package: str,
|
||||
imports: set,
|
||||
source_type: str,
|
||||
typing_compiler: "TypingCompiler",
|
||||
unwrap: bool = True,
|
||||
pydantic: bool = False,
|
||||
) -> str:
|
||||
@@ -57,7 +58,7 @@ def get_type_reference(
|
||||
if unwrap:
|
||||
if source_type in WRAPPER_TYPES:
|
||||
wrapped_type = type(WRAPPER_TYPES[source_type]().value)
|
||||
return f"Optional[{wrapped_type.__name__}]"
|
||||
return typing_compiler.optional(wrapped_type.__name__)
|
||||
|
||||
if source_type == ".google.protobuf.Duration":
|
||||
return "timedelta"
|
||||
|
||||
Reference in New Issue
Block a user