---
title: "Increasing velocity by modernizing a Python codebase"
description: "An expanding monorepo of machine learning workflows became difficult to change safely as contributors and projects multiplied, undermining the velocity it was intended to support. The team replaced requirements.txt with Poetry, using pyproject.toml for direct dependencies and poetry.lock to record transitive dependencies and hashes, while virtual environments simplified setup. Ruff standardized formatting, linting, and CI enforcement; pytest addressed corner cases and bad assumptions, and mypy added annotations and stricter checks that could expose incompatible changes across call sites. To adopt these controls incrementally, the team used ignore comments and staged remediation, including a script for mypy exceptions, while an ignored revision preserved useful git blame history. The resulting codebase was kept in better shape, enabling faster iteration with greater confidence."
---

# Increasing velocity by modernizing a Python codebase

[Ramp](https://yomu.fyi/company/ramp) · Peyton McCullough · Feb 27, 2024

**Type:** Problem & solution

## Summary

An expanding monorepo of machine learning workflows became difficult to change safely as contributors and projects multiplied, undermining the velocity it was intended to support. The team replaced requirements.txt with Poetry, using pyproject.toml for direct dependencies and poetry.lock to record transitive dependencies and hashes, while virtual environments simplified setup. Ruff standardized formatting, linting, and CI enforcement; pytest addressed corner cases and bad assumptions, and mypy added annotations and stricter checks that could expose incompatible changes across call sites. To adopt these controls incrementally, the team used ignore comments and staged remediation, including a script for mypy exceptions, while an ignored revision preserved useful git blame history. The resulting codebase was kept in better shape, enabling faster iteration with greater confidence.

## Context

A centralized repository held machine-learning workflows from across Ramp in a monorepo with unrelated projects sharing one dependency set. As the codebase and contributor count grew, dependency inconsistencies, formatting disputes, linting violations, and risky changes began to hinder development velocity.

## Approach / What changed

The team modernized the Python codebase with Poetry for dependency management, Ruff for formatting and linting, pytest for testing, and mypy for type checking. They enforced checks through CI and pre-commit tooling, adopted formatting in a dedicated commit recorded in .git-blame-ignore-revs, and introduced linting and typing rules gradually with qualified ignore comments, automated mypy annotations, unused-ignore warnings, and selected type stubs.

## Takeaways

- Poetry uses pyproject.toml for direct dependencies and poetry.lock for the complete dependency set, including hashes; poetry install also creates a virtual environment for contributors.
- Ruff handled both formatting and linting, with IDE and pre-commit integration plus CI checks that prevented incorrectly formatted pull requests from being merged.
- Mypy was introduced progressively with automated type: ignore comments, warn\_unused\_ignores enabled, stricter checks for untyped code, and partial stubs for critical libraries.

**Tags:** [mypy](https://yomu.fyi/topic/mypy), [Poetry](https://yomu.fyi/topic/poetry), [Python](https://yomu.fyi/topic/python), [Ruff](https://yomu.fyi/topic/ruff), [Testing](https://yomu.fyi/topic/testing)

- Source: [Ramp](https://builders.ramp.com/post/modernizing-a-python-codebase)
- Source URL: https://builders.ramp.com/post/modernizing-a-python-codebase
- Ingested by Yomu: 2026-09-01T01:34:12.412Z

[Read original post](https://builders.ramp.com/post/modernizing-a-python-codebase)
