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

Add to_uppercase module and its unit tests #41

Merged
merged 3 commits into from
Jan 12, 2025
Merged

Conversation

NimahMasuud
Copy link

  • Created to_uppercase.py in the solutions directory for converting strings to uppercase.
  • Added unit tests for the to_uppercase function in solutions/tests/test_to_uppercase.py.
  • Ensured PEP 8 compliance and code formatting using Ruff.
  • All tests are passing and the module is ready for integration.
  • Includes examples for handling edge cases like empty strings and non-string inputs.

@NimahMasuud NimahMasuud self-assigned this Jan 11, 2025
@NimahMasuud NimahMasuud added the code challenge challenge for CDS program label Jan 11, 2025
@KHserv-Creator KHserv-Creator self-requested a review January 11, 2025 15:14
Copy link

@KHserv-Creator KHserv-Creator left a comment

Choose a reason for hiding this comment

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

The code structure is clear, and both the function and tests are well-organized. The to_uppercase function handles input validation by raising a TypeError for non-string inputs, which is a good defensive measure. Unit tests cover basic cases well, but more edge cases (like special characters and large strings) could be added.
• The module-level and function-level docstrings are well-defined, but ensure the author and date fields are completed with accurate information (Created on XX XX XX needs to be filled in).
• Additionally, you could enhance the function's docstring to mention any edge cases handled explicitly (like empty strings).
However, the code does not pass Ruff and Pylint checks, likely due to issues like line length, unused imports, or docstring formatting. Fixing these will improve readability and maintain compliance with best practices. Since the code does not pass Ruff and Pylint linting checks, it may need further refinement in terms of:
Line lengths: Ensure that lines are not excessively long, keeping them under the standard 80 or 100 characters.
Unused imports: Check for any unused imports or variables that may trigger warnings.
Docstring style: Ensure docstrings follow the recommended format, such as using """ with proper alignment and spacing
Also, please double check the function does not called directly in the function file.
Feedback: if name == "main":
Overall, the function and tests are solid, but some refinements are needed to meet linting standards and handle more edge cases effectively. The function and tests are well-organized with clear docstrings and appropriate naming conventions. The TypeError check for non-string inputs is a good defensive measure. Including doctests in the function docstring is excellent for self-documentation. Unit tests cover the major cases, including edge cases like an empty string and non-string input. The function is simple, well-structured, and the unit tests comprehensively validate its behavior. Keep up the good work!

solutions/tests/test_to_uppercase.py Show resolved Hide resolved
@NimahMasuud
Copy link
Author

The code structure is clear, and both the function and tests are well-organized. The to_uppercase function handles input validation by raising a TypeError for non-string inputs, which is a good defensive measure. Unit tests cover basic cases well, but more edge cases (like special characters and large strings) could be added. • The module-level and function-level docstrings are well-defined, but ensure the author and date fields are completed with accurate information (Created on XX XX XX needs to be filled in). • Additionally, you could enhance the function's docstring to mention any edge cases handled explicitly (like empty strings). However, the code does not pass Ruff and Pylint checks, likely due to issues like line length, unused imports, or docstring formatting. Fixing these will improve readability and maintain compliance with best practices. Since the code does not pass Ruff and Pylint linting checks, it may need further refinement in terms of: Line lengths: Ensure that lines are not excessively long, keeping them under the standard 80 or 100 characters. Unused imports: Check for any unused imports or variables that may trigger warnings. Docstring style: Ensure docstrings follow the recommended format, such as using """ with proper alignment and spacing Also, please double check the function does not called directly in the function file. Feedback: if name == "main": Overall, the function and tests are solid, but some refinements are needed to meet linting standards and handle more edge cases effectively. The function and tests are well-organized with clear docstrings and appropriate naming conventions. The TypeError check for non-string inputs is a good defensive measure. Including doctests in the function docstring is excellent for self-documentation. Unit tests cover the major cases, including edge cases like an empty string and non-string input. The function is simple, well-structured, and the unit tests comprehensively validate its behavior. Keep up the good work!

Changes and Refinements:
• Input Validation: The to_uppercase function still handles input validation well by raising a TypeError for non-string inputs.
• Edge Cases: Additional edge cases (e.g., special characters and large strings) have been incorporated into both the function’s behavior and unit tests, enhancing robustness.
• Docstrings:
• The module and function-level docstrings have been updated with accurate author and date fields.
• The function’s docstring now explicitly mentions how it handles edge cases like empty strings and special characters.
• Linting Compliance: The code now passes both Ruff and Pylint checks. Line lengths, unused imports, and docstring formatting issues have been addressed, ensuring better readability and adherence to best practices.
• Testing Improvements:
• New unit tests for edge cases have been added.
• Test names have been refined for better clarity (e.g., test_valid_string renamed to test_lowercase_string_to_uppercase).
• Defensive Programming: Including doctests in the function’s docstring ensures self-documentation and quick validation of examples.

KHserv-Creator
KHserv-Creator previously approved these changes Jan 12, 2025
@NimahMasuud NimahMasuud dismissed KHserv-Creator’s stale review January 12, 2025 20:25

The merge-base changed after approval.

@KHserv-Creator KHserv-Creator self-requested a review January 12, 2025 21:18
KHserv-Creator
KHserv-Creator previously approved these changes Jan 12, 2025
@NimahMasuud NimahMasuud dismissed KHserv-Creator’s stale review January 12, 2025 21:18

The merge-base changed after approval.

KHserv-Creator
KHserv-Creator previously approved these changes Jan 12, 2025
@NimahMasuud NimahMasuud dismissed KHserv-Creator’s stale review January 12, 2025 21:25

The merge-base changed after approval.

emrebiyik
emrebiyik previously approved these changes Jan 12, 2025
KHserv-Creator
KHserv-Creator previously approved these changes Jan 12, 2025
@NimahMasuud NimahMasuud dismissed stale reviews from KHserv-Creator and emrebiyik January 12, 2025 21:35

The merge-base changed after approval.

@NimahMasuud NimahMasuud merged commit 4fd0f43 into main Jan 12, 2025
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code challenge challenge for CDS program
Projects
Development

Successfully merging this pull request may close these issues.

3 participants