Get the latest tech news

Refactoring Python with Tree-sitter and Jedi


I was toying around with a refactor the other day that would have taken me ages by hand as it involved 100s of files. I wanted to rename every instance of...

I wanted to rename every instance of a pytest fixture from database-> db across my entire repo (silly I know). After struggling to achieve what I wanted with the tools I'd typically reach for ( grep+ sed) I decided to try something a bit fancier. I found both jedi and tree-sitter relatively easy to learn, I'll certainly be keeping them in my toolbelt for situations where grep+ sed don't quite cut it.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of python

python

Photo of jedi

jedi

Photo of sitter

sitter

Related news:

News photo

Hy 1.0 – Lisp dialect for Python

News photo

Scientific Visualization: Python + Matplotlib (2021)

News photo

Counting Sheeps with Contracts in Python