Tighten check-datetime-timezone so the UtcDateTime rule applies to
both models and migrations. Supersedes the inverted approach in #3515,
which tried to accept sa.DateTime(timezone=True) inside migrations.
- Rewrite the AST walker: handle sa.Column / bare Column, positional
type arg at any index, bare Column(UtcDateTime) without parens (the
hook's own example), and ast.IfExp with both branches inspected
independently so a violation in either arm is still flagged.
- Anchor the path filter on src/local_deep_research/ to stop
false-positives on tests/database/models/ and partial-name matches
like database/models_backup/.
- Update .pre-commit-config.yaml name/description and the stale
CI_CD_INFRASTRUCTURE.md hook table entry.
- Add tests/hooks/test_check_datetime_timezone.py with 20 cases:
violations (models / migrations / conditional types / batch runs /
bare names), allows (UtcDateTime with import, combo import order,
empty / syntax-error files), and path-filter boundaries.
- Add sqlalchemy-utc package to handle timezone-aware datetimes
- Replace DateTime(timezone=True) with UtcDateTime in benchmark models
- Replace func.now() with utcnow() for proper UTC defaults
- Update pre-commit hook to enforce UtcDateTime usage
- Fixes timezone mismatch errors when SQLite returns naive datetimes
SQLite doesn't natively support timezone-aware datetimes, causing
issues when comparing timestamps. The sqlalchemy-utc package provides
a TypeDecorator that automatically converts between naive and aware
datetimes, ensuring consistent UTC handling across the application.
- Fixed timezone-aware/naive datetime subtraction error in benchmark
- Added timezone=True to all DateTime columns in benchmark models
- Created pre-commit hook to enforce timezone=True on DateTime columns
- Prevents future timezone-related bugs in database models