aws-cli
aws-cli copied to clipboard
chore: integrate ruff and mypy for CI/CD modernization
Summary
This PR modernizes the project's CI/CD pipeline by integrating ruff for high-performance linting and mypy for static type checking. It also includes an initial refactor of the core awscli/clidriver.py module to demonstrate these improvements, resolving legacy formatting issues and adding strict type hints.
Key Changes
- CI/CD Pipeline: Updated scripts/ci/run-check to enforce linting (
ruff) and type safety (mypy). - Dependencies: Added
ruffandmypyto requirements-check.txt. - Configuration: Added a safe
[tool.mypy]configuration to pyproject.toml that allows for incremental adoption (follow_imports = "silent"). - Refactoring (awscli/clidriver.py):
- Replaced legacy
%string formatting with modern f-strings. - Added return type annotations to critical entry points: main(), create_clidriver(), and
CLIDriver.main(). - Fixed all strict linting violations.
- Replaced legacy
Motivation
To improve long-term code maintainability and prevent type-related runtime errors. Use of modern tooling (ruff) ensures these checks remain fast, while mypy integration lays the groundwork for a fully typed codebase.
Testing
- Static Analysis:
ruffandmypychecks pass with 0 errors on the modified files. - Unit Tests: Ran tests/unit/test_clidriver.py locally; all 54 tests passed, ensuring no functional regressions.