Skip to content

minor fixes for ibims orm creation#99

Merged
DeltaDaniel merged 13 commits intomainfrom
fixes_for_sqlmodel
Sep 2, 2024
Merged

minor fixes for ibims orm creation#99
DeltaDaniel merged 13 commits intomainfrom
fixes_for_sqlmodel

Conversation

@DeltaDaniel
Copy link
Copy Markdown
Collaborator

@DeltaDaniel DeltaDaniel commented Jul 30, 2024

not only small changes anymore...

@DeltaDaniel DeltaDaniel requested a review from lord-haffi July 30, 2024 10:57
Copy link
Copy Markdown
Collaborator

@lord-haffi lord-haffi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der Python-Generator sollte nicht auf das ibims Repo zugeschnitten sein. Versuch stattdessen relative Pfade zu verwenden.

@DeltaDaniel DeltaDaniel requested a review from lord-haffi August 6, 2024 12:48
Copy link
Copy Markdown
Collaborator

@lord-haffi lord-haffi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich denke, das passt so für mich, solang es funzt ^^ Aber schau mal, ob man die eine Funktion da noch braucht..

Comment thread src/bo4e_generator/sqlparser.py Outdated
Comment on lines +375 to +385
# python_code = format_code(python_code)
return python_code


def format_code(code: str) -> str:
"""
perform isort and black on code
"""
code = remove_unused_imports(code)
code = black.format_str(code, mode=black.Mode())
return isort.code(code, known_local_folder=["borm"])
return isort.code(code)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wird format_code jetzt überhaupt noch verwendet? remove_unused_imports rufst du ja jetzt auch in generate_bo4e_schemas auf und mittlerweile sollte das Formatieren auch korrekt funktionieren, meine ich..

Comment on lines +388 to +407
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
tmp_file.write(code.encode("utf-8"))

# Run autoflake to remove unused imports
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", encoding="utf-8") as tmp_file:
cleaned_code = tmp_file.read()

# Clean up the temporary file
os.remove(tmp_file_name)

return cleaned_code
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schick 😊

@DeltaDaniel DeltaDaniel merged commit 38b1d74 into main Sep 2, 2024
@DeltaDaniel DeltaDaniel deleted the fixes_for_sqlmodel branch September 2, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants