Skip to content

feat: Added type checking infrastructure and fix type errors

Mohana Sri Bhavitha requested to merge type-checking/bhavitha into feature-final

Overview

Added static type checking with mypy and resolved 105+ type errors across the codebase.

Changes Made

Type Checking Setup

  • Installed and configured mypy as the type checker
  • Created mypy.ini with appropriate settings for the project
  • Added type stubs: types-openpyxl, types-python-dateutil, types-pytz, pandas-stubs, types-reportlab

Type Annotations Added

  • Projects/file_classifier.py: Added dict[str, int] type for counts
  • modes/team_leaderboard.py: Added dict[str, int] type for activity_map
  • gitlab_utils/client.py: Fixed _ZERO_ROW type with dict[str, Any]

Import Issues Fixed

  • Projects/ directory: Renamed files to match imports
    • complicance_checks.pycompliance_checks.py
    • compliance_Service.pycompliance_service.py
    • template_checker.pytemplates_checker.py
  • Created Projects/__init__.py to make it a proper package
  • Removed reference to non-existent vscode_checker

None Handling Fixed

  • gitlab_utils/client.py: Fixed closed_at access with default empty string
  • modes/team_leaderboard.py: Fixed None handling in string operations using or ""

Type Mismatches Fixed

  • scripts/generate_report.py: Changed elements list type to list[Flowable]
  • Added Flowable import from reportlab.platypus

Missing Functions Added

  • batch_mode/batch_service.py: Added process_single_project() stub
  • batch_mode/export_service.py: Added prepare_export_data() function
  • user_profile/profile_utils.py: Added split_projects() function

Configuration Updates

  • Updated pyproject.toml: Added N999 to ruff ignore list for 'Projects' directory
  • Created mypy.ini: Configured ignore_missing_imports for libraries without stubs

Testing

  • ruff check . - All checks passed
  • mypy . - Success - no issues found in 87 source files

Notes

  • The Projects/ directory uses uppercase naming which triggers ruff N999; ignored via configuration
  • Some third-party libraries (nest_asyncio, xlsxwriter) don't have type stubs; configured mypy to skip them

Merge request reports

Loading