First, get a read-only inventory of SQL hidden in Python files.
Find embedded SQL
Find triple-quoted strings that look like SQL, then separate safe blocks from dynamic templates before cleanup begins.
py-sql-cleaner list jobs/Shows file, variable name, line count, and whether the block is safe to rewrite.
Plain strings are marked safe. f-strings and Jinja-like templates are visible but skipped.
The list command changes nothing, so you can inspect a project before choosing a cleanup command.
jobs/*.py# jobs/load_users.py
users_query = """
select user_id, email from analytics.users
"""
# jobs/sessions.py
sessions_query = f"""
select * from sessions where ds = '{run_date}'
"""py-sql-cleaner list jobs/jobs/load_users.py:14users_query18 linessafejobs/load_users.py:42events_sql24 linessafejobs/sessions.py:11sessions_query31 linesskip · f-stringjobs/orders.py:67orders_sql12 linessafejobs/cohorts.py:29cohort_query44 linesskip · jinja