Skip to content

Chore: Enable raises for assert #583

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cidrblock
Copy link
Contributor

Fix DOC504 pydoclint errors by adding Raises sections to test docstrings

Summary

This PR resolves all DOC504 pydoclint errors by adding proper "Raises" sections to test function docstrings that contain assert statements. Instead of suppressing these errors in the baseline file, we've chosen to properly document that test functions can raise AssertionError when their assertions fail.

Changes Made

Updated Test Files

Added Raises: AssertionError sections with descriptive messages to the following test files:

  • tests/integration/test_cli.py (2 functions)

    • test_version() - Documents assertion failures for version output validation
    • test_server_fail_no_deps() - Documents assertion failures for error message validation
  • tests/unit/test_basic.py (2 functions)

    • test_main() - Documents assertion failures for expected error code validation
    • test_cli_main() - Documents assertion failures for expected error code validation
  • tests/unit/test_server_utils.py (4 functions)

    • test_validate_request_pass() - Documents assertion failures for validation results
    • test_validate_request_fail() - Documents assertion failures for unexpected validation passes
    • test_validate_response_pass() - Documents assertion failures for validation results
    • test_validate_response_fail() - Documents assertion failures for unexpected validation passes
  • tests/integration/test_server_creator_v1.py (3 functions)

    • test_error_v1() - Documents assertion failures for response validation
    • test_playbook_v1() - Documents assertion failures for response validation
    • test_collection_v1() - Documents assertion failures for response validation
  • tests/integration/test_server_creator_v2.py (3 functions)

    • test_error_v2() - Documents assertion failures for response validation
    • test_playbook_v2() - Documents assertion failures for response validation
    • test_collection_v2() - Documents assertion failures for response validation
  • tests/integration/test_server_info.py (1 function)

    • test_metadata() - Documents assertion failures for response validation
  • tests/unit/test_server.py (1 function)

    • test_server_debug_options() - Documents assertion failures for server option validation
  • tests/integration/test_container.py (12 functions)

    • Various container test functions documenting assertion failures for their specific validation scenarios

Total Impact

  • 28 test functions updated across 8 test files
  • All DOC504 errors resolved without using baseline suppression
  • Improved documentation clarity for test failure scenarios

Rationale

Rather than suppressing these linting errors in the baseline file, we chose to properly document the AssertionError exceptions that test functions can raise. This approach:

  1. Maintains documentation standards - All functions with assert statements now properly document their potential exceptions
  2. Improves code clarity - Developers can easily understand what conditions cause test failures
  3. Follows best practices - Proper exception documentation is preferred over error suppression
  4. Keeps linting clean - No baseline exceptions needed, maintaining a clean linting workflow

Testing

  • All existing functionality remains unchanged
  • Only docstring documentation was added
  • No behavioral changes to test execution
  • Linting should now pass without DOC504 errors

Files Changed

tests/integration/test_cli.py
tests/integration/test_container.py  
tests/integration/test_server_creator_v1.py
tests/integration/test_server_creator_v2.py
tests/integration/test_server_info.py
tests/unit/test_basic.py
tests/unit/test_server.py
tests/unit/test_server_utils.py

@Qalthos Qalthos force-pushed the chore_assert_raises branch from 795c824 to 98225aa Compare July 8, 2025 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

2 participants