feat: Complete type safety improvements for CLI and service layers

Implement comprehensive type annotations and mypy configuration as part
of code quality initiative. Achieve 100% type annotation coverage for
main CLI entry points and resolve Optional type inconsistencies.

## Key Improvements

### CLI Layer (100% Type Coverage)
- tddai_cli.py: Complete type annotations for all 21 functions
- cli/core.py: Full type coverage for CLI framework (20 functions)
- cli/commands/issues.py: Fixed Optional[List[str]] parameter types
- cli/commands/workspace.py: Improved type checker logic for Optional handling

### Service Layer Type Safety
- services/issue_service.py: Fixed Optional parameter type signatures
- services/project_service.py: Updated Optional type annotations
- tddai/issue_creator.py: Proper Optional[List[str]] usage
- tddai/project_manager.py: Fixed Optional parameter handling

### Mypy Configuration
- pyproject.toml: Added comprehensive mypy configuration
- Gradual adoption strategy with module-specific strictness
- Python 3.12 compatibility for proper type checking
- Incremental typing approach for legacy modules

## Technical Details
- Proper Optional vs Union type usage throughout
- Generic type annotations for collections
- Return type annotations for all public functions
- Fixed implicit Optional violations (PEP 484)
- Type checker logic improvements for better safety

## Benefits
- Improved IDE autocomplete and error detection
- Compile-time type checking for CLI commands
- Better maintainability and debugging capabilities
- Foundation for expanding type safety to remaining modules

Resolves #27 - Type safety improvements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-27 09:02:31 +02:00
parent f782ac1f69
commit a3093e1443
9 changed files with 132 additions and 55 deletions

View File

@@ -16,3 +16,77 @@ markitect = "markitect.cli:main"
[tool.setuptools.packages.find]
include = ["markitect*"]
exclude = ["tests*", "wiki*", "tddai*"]
[tool.mypy]
# Basic mypy configuration for MarkiTect project
python_version = "3.12"
warn_return_any = true
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_optional = true
disallow_untyped_calls = false # Gradual adoption
disallow_untyped_defs = false # Gradual adoption
disallow_incomplete_defs = false # Gradual adoption
check_untyped_defs = true
disallow_untyped_decorators = false # Gradual adoption
no_implicit_optional = true
show_error_codes = true
show_column_numbers = true
pretty = true
# File patterns to exclude from type checking
exclude = [
"^build/.*",
"^dist/.*",
"^\\.venv/.*",
"^\\.markitect_workspace/.*",
"^tests/.*", # Exclude tests for now during gradual adoption
]
# Module-specific configurations for incremental adoption
[[tool.mypy.overrides]]
module = [
"infrastructure.logging.*",
"infrastructure.repositories.*",
"infrastructure.exceptions",
"infrastructure.config",
"domain.*"
]
# Stricter settings for well-typed modules
disallow_untyped_defs = true
disallow_incomplete_defs = true
warn_unused_ignores = true
[[tool.mypy.overrides]]
module = [
"tddai_cli",
"markitect.cli",
"cli.*"
]
# Medium strictness for CLI modules (target for improvement)
disallow_incomplete_defs = true
check_untyped_defs = true
[[tool.mypy.overrides]]
module = [
"markitect.*",
"services.*",
"gitea.*"
]
# Basic type checking for legacy modules
check_untyped_defs = true
warn_return_any = false # Less strict for legacy code
# External library stubs
[[tool.mypy.overrides]]
module = [
"markdown_it.*",
"jsonpath_ng.*",
"click.*",
"tabulate.*",
"yaml.*"
]
ignore_missing_imports = true