Created
June 15, 2021 12:11
-
-
Save LouisdeBruijn/b17a4b564a331a007a7d776e808cccef to your computer and use it in GitHub Desktop.
This file contains 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
with open(script, "r") as file: | |
script_lines = file.readlines() | |
function_docs.sort(key=lambda x: x[0], reverse=True) | |
for (idx, docstring_attr) in function_docs: | |
script_lines = ( | |
script_lines[: docstring_attr["begin_lineno"] - 1] | |
+ [f'{docstring_attr["value"]}\n'] | |
+ script_lines[docstring_attr["end_lineno"] :] | |
) | |
if overwrite_script: | |
with open(script, "w") as script_file: | |
script_file.writelines(script_lines) | |
print(f"Automated docstring generation from type hints: {script}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment