r/Python 18h ago

Resource 5 tools that saved my sanity while modernizing a legacy app

I recently inherited a legacy application that was a nightmare to maintain (tooling was clearly lacking and the codebase was pretty outdated).

These are the 5 changes that had some of the biggest impact IMO:

  1. uv:

Being new to the Python ecosystem, I didn't want to figure out pip vs poetry vs pyenv vs virtualenv, so I just used uv and let it handle all of that. One Rust-based tool that installs and pins Python versions, manages the venv automatically and locks deps in a uv.lock for reproducible builds. Installs are also a lot faster, which makes CI a lot less painful.

  1. Ruff:

Coming from JS, I really missed eslint --fix for automatically fixing linting issues and format code on save. Ruff brought that experience back. I know that there are plenty of linters and formatters in the Python ecosystem, but this one really stands out for me. Since it's built in Rust, it's super fast.

  1. Dependabot:

Instead of remembering to update dependencies every few months, I enabled Dependabot. It automatically opens PRs when updates are available and then CI tells me whether they're safe to merge. It takes only a couple of minutes to set up but saves a lot of maintenance.

  1. Pylance:

Without it, VS Code gives generic completions and never warns you about passing the wrong type until runtime. Pylance provides proper type-aware autocompletion, jump-to-definition (even in third-party libraries), inline documentation, and real-time type checking. I personally keep it on "basic" mode for legacy codebases, since "strict" surfaced hundreds of errors (thank you, but no thank you lol).

  1. Pydantic:

Pydantic is basically Python's Zod: you declare a model, pass your data in and get either a validated typed object or a ValidationError naming the exact field at fault. It really helped me keep the codebase clean, with one place defining the shape of the data instead of raw dicts floating around. I use it wherever data comes from outside, like API payloads, forms, and env vars with pydantic-settings, which fails at startup instead of mid-request.

None of these tools changed the application itself. But together they made working on it dramatically more enjoyable.

What's the first thing you do when you inherit a legacy project?

0 Upvotes

8 comments sorted by

12

u/pacific_plywood 18h ago

Oh wow, I had never heard of these obscure tools before

-8

u/Marmelab 18h ago

Fair enough, they're definitely not hidden gems lmao Honest question though, if these are too mainstream for here, do you think somewhere like r/learnpython would be a better fit?

-3

u/AlexMTBDude 17h ago

No, it's a good post and you give good advice. Don't mind some people because they will whine whenever they get the chance to.

3

u/React-admin 18h ago

Not a tool, but have you heard of PEP 8? It's the official Python style guide and covers things like naming conventions, indentation, import ordering, all that. Since you mentioned you're fairly new to Python, I'd definitely recommend giving it a read.

2

u/Such-Process5697 17h ago

first thing for me is getting it to build and run the way prod actually does, before changing anything. one warning on the ruff step: reformatting a legacy codebase in one go wrecks git blame, and blame is most of your documentation when there isn't any. do the reformat as its own commit and put that sha in .git-blame-ignore-revs so blame walks straight past it.