remove relative imports

This commit is contained in:
Waylon Walker 2023-03-13 10:14:34 -05:00
parent 6950680ee9
commit cf757847ad
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4

View file

@ -49,6 +49,10 @@ def main(
callback=verbose_callback, callback=verbose_callback,
help="show the log messages", help="show the log messages",
), ),
relative_imports: bool = typer.Option(
False,
help="include relative imports",
),
) -> None: ) -> None:
lines = [] lines = []
@ -58,6 +62,8 @@ def main(
files = Path(".").glob("**/*.py") files = Path(".").glob("**/*.py")
files = [file for file in files if not spec.match_file(str(file))] files = [file for file in files if not spec.match_file(str(file))]
imports = more_itertools.flatten([get_imports(p.read_text()) for p in files]) imports = more_itertools.flatten([get_imports(p.read_text()) for p in files])
if not relative_imports:
imports = [i for i in imports if "from ." not in i]
print("\n".join(set(imports))) print("\n".join(set(imports)))