Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes for ibims orm creation #99

Merged
merged 13 commits into from
Sep 2, 2024
Merged

minor fixes for ibims orm creation #99

merged 13 commits into from
Sep 2, 2024

Conversation

DeltaDaniel
Copy link
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
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
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 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
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
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
13 checks passed
@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