How to Run Linting and Type Checking for OpenSRE Development
Run make lint to run ruff linting on the app/ and tests/ directories, make typecheck to run mypy static analysis, or make check to execute both checks plus the full test suite in the Tracer-Cloud/opensre repository.
The Tracer-Cloud/opensre project enforces code quality through automated tooling integrated into its build system. To run linting and type checking for OpenSRE development, developers invoke standardized Makefile targets that execute ruff for high-performance linting and formatting and mypy for rigorous static type validation.
Linting and Formatting with Ruff
The repository uses ruff as its primary linter and code formatter. Ruff scans the app/ and tests/ packages for style violations, unused imports, and other code-quality issues.
Running the Linter
The lint target in the Makefile (lines 79-82) executes ruff check against the source directories.
make lint
This command validates syntax and style across the codebase without modifying files.
Auto-Formatting Code
To automatically fix many linting concerns and enforce consistent formatting, use the format target defined at lines 84-86 of the Makefile.
make format
This runs ruff format to restructure code according to the project's style guidelines.
Static Type Checking with Mypy
For static type analysis, OpenSRE integrates mypy to validate type hints throughout the app/ package.
Configuration in mypy.ini
The mypy.ini file in the repository root configures the type checker for Python 3.12. It includes ignore rules for missing stubs from third-party libraries such as boto3, kubernetes, and requests, ensuring smooth execution without requiring every external type definition.
[mypy]
python_version = 3.12
ignore_missing_imports = True
Running Type Checks
Execute the typecheck target from lines 88-90 of the Makefile to run mypy against the application code.
make typecheck
This validates that type hints in the app/ directory are consistent and correctly implemented.
Combined Quality Checks
For comprehensive validation that mirrors the CI pipeline, use the check target defined at lines 92-93 of the Makefile. This composite command sequentially runs linting, type checking, and the full test suite.
make check
This ensures that new code meets all quality gates—style, type safety, and functionality—before it is merged.
Makefile Targets and CI Integration
The Makefile serves as the single source of truth for quality assurance commands. The following targets are relevant for linting and type checking:
make lint– Runsruff checkonapp/andtests/make format– Runsruff formatto auto-fix style issuesmake typecheck– Runsmypyon theapp/packagemake check– Executes lint, typecheck, and tests sequentially
These targets are invoked in the CI pipeline to enforce consistency between local development and automated builds.
Summary
- Ruff handles linting and formatting via
make lintandmake format, scanning theapp/andtests/directories. - Mypy performs static type checking via
make typecheck, configured throughmypy.iniwith Python 3.12 settings. - The
make checkcommand runs both tools plus the full test suite, replicating CI quality gates locally. - Configuration files
Makefileandmypy.iniin the repository root define these workflows for the Tracer-Cloud/opensre project.
Frequently Asked Questions
What tools does OpenSRE use for linting and type checking?
OpenSRE uses ruff for linting and code formatting, and mypy for static type checking. Ruff scans for style violations and unused imports, while mypy validates type hints throughout the codebase.
Where is the mypy configuration stored in the OpenSRE repository?
The mypy configuration is stored in mypy.ini at the root of the repository. This file specifies Python 3.12 as the target version and configures ignore rules for missing stubs from third-party libraries like boto3, kubernetes, and requests.
How do I run all quality checks at once in OpenSRE?
Run make check from the repository root. This Makefile target sequentially executes the lint, typecheck, and test targets, ensuring your code passes style, type safety, and functional validation in a single command.
Which directories are scanned by the linter in OpenSRE?
The linter scans the app/ and tests/ directories. The make lint command runs ruff check specifically against these packages to detect style violations, syntax errors, and unused imports throughout the source code and test suites.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →