minor fixes for ibims orm creation#99
Merged
DeltaDaniel merged 13 commits intomainfrom Sep 2, 2024
Merged
Conversation
lord-haffi
reviewed
Jul 30, 2024
Collaborator
lord-haffi
left a comment
There was a problem hiding this comment.
Der Python-Generator sollte nicht auf das ibims Repo zugeschnitten sein. Versuch stattdessen relative Pfade zu verwenden.
hf-sheese
approved these changes
Jul 30, 2024
lord-haffi
approved these changes
Sep 1, 2024
Collaborator
lord-haffi
left a comment
There was a problem hiding this comment.
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) |
Collaborator
There was a problem hiding this comment.
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
not only small changes anymore...