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

Ml2 write docstring to file #19

Merged
merged 21 commits into from
Jan 17, 2025
Merged

Ml2 write docstring to file #19

merged 21 commits into from
Jan 17, 2025

Conversation

Lukman-Lateef
Copy link
Collaborator

No description provided.

@Lukman-Lateef Lukman-Lateef added the enhancement New feature or request label Jan 17, 2025
@Lukman-Lateef Lukman-Lateef added this to the Milestone 2 milestone Jan 17, 2025
@Lukman-Lateef Lukman-Lateef self-assigned this Jan 17, 2025
@Farhan-Faisal Farhan-Faisal linked an issue Jan 17, 2025 that may be closed by this pull request
Copy link
Collaborator

@mikem2m mikem2m left a comment

Choose a reason for hiding this comment

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

Looks good @Lukman-Lateef. Just some feedback you might want to / might not want to implement

if not isinstance(docstring, str) or not docstring.strip():
raise ValueError("The docstring is empty, None, or contains only whitespace")

print("Generated Docstring:\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need these 3 print statements

try:
with open(output_file, 'w') as file:
file.write(docstring)
print(f"Docstring successfully written to {output_file}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

file.write(docstring)
print(f"Docstring successfully written to {output_file}")
except Exception as e:
print(f"An error occurred while writing to the file: {e}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can keep this, but use raise ValueError instead :)

"""Fixture for an empty docstring."""
return " "

def test_print_only(valid_docstring, capsys):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we don't need this test, but damn I didnt know you could do that. Good stuff though

@Lukman-Lateef Lukman-Lateef merged commit d93049c into main Jan 17, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

2.1: Function 1 - write_docstring_to_file
2 participants