We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5b9fefe + 41beca1 commit 9d410f3Copy full SHA for 9d410f3
tools/extract_pyi.py
@@ -228,7 +228,8 @@ def convert_folder(top_level, stub_directory):
228
imports, type_imports = extract_imports(tree)
229
import_lines = ["from __future__ import annotations"]
230
for type_module, used_types in type_imports.items():
231
- import_lines.append(f"from {type_module} import {', '.join(sorted(used_types))}")
+ if used_types:
232
+ import_lines.append(f"from {type_module} import {', '.join(sorted(used_types))}")
233
import_lines.extend(f"import {m}" for m in sorted(imports))
234
import_body = "\n".join(import_lines)
235
m = re.match(r'(\s*""".*?""")', stub_contents, flags=re.DOTALL)
0 commit comments