feat: Add mypy CI job and enforce stricter type checking
Overview
Added mypy type checking as a CI job and enabled stricter type checking configuration to catch potential type errors at lint time.
Changes
CI Integration
-
.gitlab-ci.yml: Addedmypyjob inteststage- Runs
uv run mypyon all backend code directories - Reuses existing
before_scriptfor dependency setup (no duplication) - Same trigger rules as other jobs (MRs, default branch, feature-final)
- Runs
Configuration
-
mypy.ini: Updated with stricter settings-
warn_return_any = True- Warn when returning Any from typed functions -
strict_optional = True- Handle Optional types more strictly -
no_implicit_optional = True- Require explicit Optional for nullable params -
warn_redundant_casts = True- Catch unnecessary type casts -
warn_unused_ignores = True- Keep ignore comments clean -
show_error_codes = True- Display error codes for better debugging -
pretty = True- Formatted error output - Excluded
tests/*from type checking
-
Bug Fix
-
gitlab_utils/files_reader.py: Fixed type error- Added
isinstance(content, bytes)check before decode - Returns proper
strtype instead ofAny
- Added
Testing
| Check | Status |
|---|---|
ruff check . |
|
mypy . |
|
Behavior
- Pipeline: mypy now runs automatically on every push and MR
- Failure: CI fails if type errors are present
- Success: CI passes when all type checks pass
- No breaking changes: Existing pipeline behavior preserved