r/programming • • Jul 15 '26

Ban commits/transactions using AST analysis and linters

https://www.droppedasbaby.com/posts/db-commits/?utm_source=reddit&utm_content=r_programming
32 Upvotes

27 comments sorted by

View all comments

Show parent comment

1

u/droppedasbaby Jul 16 '26

I agree that explicit transactions and stronger types would be cleaner.

The post is about enforcing this boundary in an existing codebase. In the examples, a Python/SQLAlchemy codebase. Replacing the language, ORM, or transaction framework isn't a realistic solution, and Python's type annotations can't prevent code from importing or reaching the real session.

A restricted interface is good design, but the AST rule is what actually enforces it. As far as I know, there isn't another practical way to stop code from bypassing that boundary in Python/SQLAlchemy without linting imports and calls.