Skip to content

refactor: extract validation and path utilities to utils module (closes #3)#34

Open
DrGalio wants to merge 1 commit intoApexOpsStudio:mainfrom
DrGalio:refactor/extract-validation-utils
Open

refactor: extract validation and path utilities to utils module (closes #3)#34
DrGalio wants to merge 1 commit intoApexOpsStudio:mainfrom
DrGalio:refactor/extract-validation-utils

Conversation

@DrGalio
Copy link

@DrGalio DrGalio commented Mar 25, 2026

Summary

Extracts all input validation logic and shared path helpers into a dedicated utils/ module, eliminating code duplication across command files.

Changes

  • utils/__init__.py: New module package
  • utils/paths.py: Shared path helpers (get_config_path, get_tasks_file)
  • utils/validation.py: All validation functions (validate_description, validate_task_id, validate_task_file)
  • commands/add.py: Now imports validate_description from utils
  • commands/done.py: Now imports validate_task_id from utils
  • commands/list.py: Now imports validate_task_file from utils
  • task.py: Uses get_config_path from utils
  • test_task.py: Updated imports to use utils
  • .gitignore: Added for pycache and .pytest_cache

Testing

All existing tests pass:

test_task.py::test_validate_description PASSED
test_task.py::test_validate_task_id PASSED

CLI functionality verified:

$ python3 task.py add 'Test task'
Added task 1: Test task
$ python3 task.py list
[ ] 1. Test task

Acceptance Criteria

  • All validation logic in utils/validation.py
  • All path helpers in utils/paths.py
  • All commands updated to use shared utilities
  • Tests still pass (no behavior changes)
  • No duplicate validation code in command files

Closes #3

- Create utils/ directory with __init__.py
- Create utils/validation.py with validate_description, validate_task_id, validate_task_file
- Create utils/paths.py with get_config_path, get_tasks_file
- Update commands/add.py to import from utils
- Update commands/done.py to import from utils
- Update commands/list.py to import from utils
- Update test_task.py to import from utils
- Update task.py to use get_config_path from utils
- Add .gitignore for __pycache__ and .pytest_cache

No behavior changes - all existing tests pass.

Closes ApexOpsStudio#3
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.

Refactor: Extract validation to utils module

1 participant