# How to Run Linting and Type Checking for OpenSRE Development

> Learn how to run linting and type checking for OpenSRE development in the Tracer-Cloud/opensre repository. Execute ruff, mypy, and test suite checks with simple make commands.

- Repository: [Tracer/opensre](https://github.com/Tracer-Cloud/opensre)
- Tags: how-to-guide
- Published: 2026-04-18

---

**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.

```bash
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`.

```bash
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`](https://github.com/Tracer-Cloud/opensre/blob/main/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.

```ini
[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.

```bash
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.

```bash
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`** – Runs `ruff check` on `app/` and `tests/`
- **`make format`** – Runs `ruff format` to auto-fix style issues
- **`make typecheck`** – Runs `mypy` on the `app/` package
- **`make 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 lint` and `make format`, scanning the `app/` and `tests/` directories.
- **Mypy** performs static type checking via `make typecheck`, configured through [`mypy.ini`](https://github.com/Tracer-Cloud/opensre/blob/main/mypy.ini) with Python 3.12 settings.
- The `make check` command runs both tools plus the full test suite, replicating CI quality gates locally.
- Configuration files `Makefile` and [`mypy.ini`](https://github.com/Tracer-Cloud/opensre/blob/main/mypy.ini) in 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`](https://github.com/Tracer-Cloud/opensre/blob/main/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.