Skip to content

refactor: Minor code style improvements (Issue #166)#170

Merged
raifdmueller merged 1 commit intodevelopfrom
refactor/code-style-166
Jan 24, 2026
Merged

refactor: Minor code style improvements (Issue #166)#170
raifdmueller merged 1 commit intodevelopfrom
refactor/code-style-166

Conversation

@raifdmueller
Copy link
Collaborator

Summary

Addresses all 5 code style improvements from Issue #166.

Changes

1. ParseWarning.type as Enum

  • Added WarningType enum with UNCLOSED_BLOCK, UNCLOSED_TABLE values
  • Changed ParseWarning.type from str to WarningType
  • Added Enum serialization support to _convert_value()
  • Updated CLI and MCP to use .value for JSON output

2. Remove redundant pass in Exception classes

  • FileReadError and FileWriteError already have docstrings
  • Removed unnecessary pass statements

3. Move datetime imports to top of file

  • Removed duplicate from datetime import UTC, datetime inside functions
  • Added import at module level in cli.py

4. Extract _compute_hash() helper function

def _compute_hash(content: str) -> str:
    """Compute 8-character MD5 hash for optimistic locking."""
    return hashlib.md5(content.encode("utf-8")).hexdigest()[:8]
  • Used in update() and insert() commands

5. Remove stale TODO and update code

  • SourceLocation now has end_line field
  • Updated API to use elem.source_location.end_line or elem.source_location.line

Files Changed

File Change
models.py Added WarningType enum, updated ParseWarning
asciidoc_parser.py Use WarningType enum
cli.py Import cleanup, hash helper
mcp_app.py Use WarningType.value
file_handler.py Remove redundant pass
api/content.py Remove stale TODO, use end_line

Test Plan

  • All 435 tests pass
  • Linting passes
  • No behavior changes (JSON output unchanged)

Closes #166

🤖 Generated with Claude Code

1. ParseWarning.type as Enum
   - Add WarningType enum with UNCLOSED_BLOCK, UNCLOSED_TABLE
   - Update ParseWarning to use WarningType instead of str
   - Add Enum serialization to _convert_value()
   - Update CLI and MCP to use .value for JSON output

2. Remove redundant `pass` in Exception classes
   - FileReadError and FileWriteError already have docstrings

3. Move datetime imports to top of file
   - Remove duplicate imports inside metadata() function
   - Import UTC, datetime at module level

4. Extract _compute_hash() helper function
   - DRY: Single function for MD5 hash computation
   - Used in update() and insert() commands

5. Remove stale TODO and update code
   - SourceLocation now has end_line field
   - Use elem.source_location.end_line in API response

All 435 tests passing, no behavior changes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@raifdmueller raifdmueller merged commit 7859c36 into develop Jan 24, 2026
@raifdmueller raifdmueller deleted the refactor/code-style-166 branch January 24, 2026 20:42
rdmueller added a commit that referenced this pull request Jan 26, 2026
1. ParseWarning.type as Enum
   - Add WarningType enum with UNCLOSED_BLOCK, UNCLOSED_TABLE
   - Update ParseWarning to use WarningType instead of str
   - Add Enum serialization to _convert_value()
   - Update CLI and MCP to use .value for JSON output

2. Remove redundant `pass` in Exception classes
   - FileReadError and FileWriteError already have docstrings

3. Move datetime imports to top of file
   - Remove duplicate imports inside metadata() function
   - Import UTC, datetime at module level

4. Extract _compute_hash() helper function
   - DRY: Single function for MD5 hash computation
   - Used in update() and insert() commands

5. Remove stale TODO and update code
   - SourceLocation now has end_line field
   - Use elem.source_location.end_line in API response

All 435 tests passing, no behavior changes.

Co-authored-by: Ralf D. Müller <ralf.d.mueller@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants