Skip to content

fix: Refactor validation to utils module + fix config crash (#2, #3)#41

Open
zlplzp123wyt wants to merge 1 commit intoApexOpsStudio:mainfrom
zlplzp123wyt:fix/refactor-validation-and-config
Open

fix: Refactor validation to utils module + fix config crash (#2, #3)#41
zlplzp123wyt wants to merge 1 commit intoApexOpsStudio:mainfrom
zlplzp123wyt:fix/refactor-validation-and-config

Conversation

@zlplzp123wyt
Copy link
Copy Markdown

Summary

This PR fixes two bounty issues:

Issue #3 ($100) - Refactor: Extract validation to utils module

  • Created utils/validation.py with validate_description, validate_task_id, validate_task_file
  • Created utils/paths.py with get_tasks_file, get_config_path, load_config
  • Removed duplicate get_tasks_file() from all three command files (add.py, list.py, done.py)
  • Updated all command imports to use shared utilities
  • No behavior changes - pure refactor
  • All existing tests pass + added new tests

Issue #2 ($75) - Fix: Crash when config file missing

  • load_config() now returns None when config doesn't exist instead of crashing with FileNotFoundError
  • task.py shows a helpful warning message when config is missing:
    Warning: No config file found at ~/.config/task-cli/config.yaml
    Using default settings. Create a config file to customize behavior.
    

Changes

  • New files: utils/__init__.py, utils/validation.py, utils/paths.py, .gitignore
  • Modified: task.py, commands/add.py, commands/list.py, commands/done.py, test_task.py
  • Tests: All 5 tests pass (2 original + 3 new for utils)
$ python3 -m pytest test_task.py -v
test_task.py::test_validate_description PASSED
test_task.py::test_validate_task_id PASSED
test_task.py::test_get_tasks_file PASSED
test_task.py::test_get_config_path PASSED
test_task.py::test_load_config_missing PASSED

/claim #2 #3

Fixes ApexOpsStudio#2 - Config crash when file missing:
- load_config() now returns None instead of crashing
- task.py shows helpful warning message when config not found

Fixes ApexOpsStudio#3 - Extract validation to utils module:
- Created utils/validation.py with validate_description, validate_task_id, validate_task_file
- Created utils/paths.py with get_tasks_file, get_config_path, load_config
- Removed duplicate get_tasks_file() from all command files
- Updated commands/add.py, commands/list.py, commands/done.py to use shared utils
- Updated tests to import from utils instead of commands
- All 5 tests pass

Also added .gitignore for Python cache files.
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.

1 participant