mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-10 00:34:29 +00:00
fix bad typing import generation in meta stubfile generator
This commit is contained in:
parent
025832aa3d
commit
81006b64ec
1 changed files with 3 additions and 1 deletions
|
@ -24,6 +24,7 @@ def generate_ndarray_stub() -> str:
|
||||||
# Create import statements, saving aliased name of type if needed
|
# Create import statements, saving aliased name of type if needed
|
||||||
if arr.__module__.startswith("numpydantic") or arr.__module__ == "typing":
|
if arr.__module__.startswith("numpydantic") or arr.__module__ == "typing":
|
||||||
type_name = str(arr) if arr.__module__ == "typing" else arr.__name__
|
type_name = str(arr) if arr.__module__ == "typing" else arr.__name__
|
||||||
|
if arr.__module__ != "typing":
|
||||||
import_strings.append(f"from {arr.__module__} import {type_name}")
|
import_strings.append(f"from {arr.__module__} import {type_name}")
|
||||||
else:
|
else:
|
||||||
# since other packages could use the same name for an imported object
|
# since other packages could use the same name for an imported object
|
||||||
|
@ -39,6 +40,7 @@ def generate_ndarray_stub() -> str:
|
||||||
type_names.append(type_name)
|
type_names.append(type_name)
|
||||||
|
|
||||||
import_strings.extend(_BUILTIN_IMPORTS)
|
import_strings.extend(_BUILTIN_IMPORTS)
|
||||||
|
import_strings = list(dict.fromkeys(import_strings))
|
||||||
import_string = "\n".join(import_strings)
|
import_string = "\n".join(import_strings)
|
||||||
|
|
||||||
class_union = " | ".join(type_names)
|
class_union = " | ".join(type_names)
|
||||||
|
|
Loading…
Reference in a new issue