From 6d37082f88d6d9743f2631f2c78db2a959cec6ad Mon Sep 17 00:00:00 2001 From: DeltaDaniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:11:48 +0200 Subject: [PATCH] fixed linting --- src/bo4e_generator/sqlparser.py | 5 ++++- unittests/test_sqlparser.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bo4e_generator/sqlparser.py b/src/bo4e_generator/sqlparser.py index f9f884f..4c72542 100644 --- a/src/bo4e_generator/sqlparser.py +++ b/src/bo4e_generator/sqlparser.py @@ -386,6 +386,9 @@ def format_code(code: str) -> str: def remove_unused_imports(code): + """ + Removes unused imports from the given code using autoflake. + """ # Create a temporary file with tempfile.NamedTemporaryFile(suffix=".py", delete=False) as tmp_file: tmp_file_name = tmp_file.name @@ -395,7 +398,7 @@ def remove_unused_imports(code): subprocess.run(["autoflake", "--remove-all-unused-imports", "--in-place", tmp_file_name], check=True) # Read the cleaned code from the temporary file - with open(tmp_file_name, "r") as tmp_file: + with open(tmp_file_name, "r", encoding="utf-8") as tmp_file: cleaned_code = tmp_file.read() # Clean up the temporary file diff --git a/unittests/test_sqlparser.py b/unittests/test_sqlparser.py index a5544aa..9df5287 100644 --- a/unittests/test_sqlparser.py +++ b/unittests/test_sqlparser.py @@ -8,7 +8,6 @@ from bo4e_generator.sqlparser import ( adapt_parse_for_sql, create_sql_field, - format_code, remove_pydantic_field_import, return_ref, write_many_many_links,