Skip to main content

Function Diff

Compare function-level changes in Python files between two Git refs (branches, tags, or SHAs). Reports added, removed, and modified functions/methods—useful for reviews and CI.

Install

pip install function-diff

Requires Python 3.8+ and Git on PATH.

CLI

function-diff <base_ref> <target_ref> [options]

function-diff main feature-branch
function-diff main HEAD --include-added
function-diff main HEAD --repo-path /path/to/repo
function-diff main feature --repo-url https://github.com/user/repo.git
function-diff main HEAD --send-email   # needs EMAIL_* (see below)

function-diff --version
function-diff --help

If you run from a Git checkout and omit --repo-path, the current directory is used when it contains .git. Otherwise set --repo-url or FUNCTION_DIFF_REPO_URL.

Python API

from function_diff import analyze, print_report, build_html_report

report = analyze(None, "main", "feature", repo_path=".")
print_report(report, include_added=True)
html = build_html_report(report, include_added=False)

Email from code: from function_diff.emailer import send_function_diff_email (set EMAIL_USER, EMAIL_PASS, EMAIL_TO; optional EMAIL_FROM, EMAIL_CC, SMTP_HOST, SMTP_PORT).

Environment variables

Variable When Notes
EMAIL_USER --send-email / send_function_diff_email SMTP login
EMAIL_PASS same App password or SMTP secret
EMAIL_TO same Comma-separated recipients
EMAIL_FROM optional From header; default EMAIL_USER (use for Azure “send as”)
EMAIL_CC optional Comma-separated CC
SMTP_HOST optional Default smtp.gmail.com
SMTP_PORT optional Default 587 (STARTTLS)
GITHUB_REPOSITORY optional Shown in HTML email
BASE_REF / TARGET_REF optional Override CLI refs
FUNCTION_DIFF_REPO_URL optional Clone URL when not using --repo-path
GH_PAT private HTTPS clone Use with Git credential helper or embed in clone URL

Gmail: SMTP_HOST=smtp.gmail.com, SMTP_PORT=587.
Azure / Microsoft 365: often SMTP_HOST=smtp.office365.com, SMTP_PORT=587; set EMAIL_USER to the mailbox that authenticates and EMAIL_FROM to the visible sender if they differ.

GitHub Actions (minimal)

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- uses: actions/setup-python@v5
  with:
    python-version: "3.12"
- run: pip install function-diff
- run: |
    function-diff \
      ${{ github.event.pull_request.base.ref }} \
      ${{ github.event.pull_request.head.ref }} \
      --repo-path ${{ github.workspace }}

For email, pass secrets as EMAIL_USER, EMAIL_PASS, EMAIL_TO, etc., and add --send-email when appropriate.

How it works

Changed .py files between the two refs are diffed at the AST level: top-level functions and class methods (as Class.method) are hashed; decorator or body changes count as modified.

Optional: if zephyr-jira-linker is on PATH, branch names with a Jira key can enrich the email “implementor” field.

Examples

See examples/ and examples/usage_examples.py.

Maintainer docs

Build, publish, and contributing notes: DEVELOPMENT.md. Version history: CHANGELOG.md.

License

MIT — see LICENSE.

Author

Pandiyaraj Karuppasamy — pandiyarajk@live.com · GitHub · PyPI

Metadata

Release files for function-diff 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for function-diff 0.1.1
File Size Uploaded Provenance
function_diff-0.1.1.tar.gz 18.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for function-diff 0.1.1
File Interpreter ABI Platform
function_diff-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / function_diff-0.1.1.tar.gz

Download URL function_diff-0.1.1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8ac7ecbb8573f341c94a5d130f4539aafbf356d7e66feaac10fff1fae145138d
BLAKE2b-256 checksum
How to use checksums
3501e64c8e5489243758f75b4988c4a50d562f1ac9860961fcbc191722614730
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / function_diff-0.1.1-py3-none-any.whl

Download URL function_diff-0.1.1-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f176f85317806c63ccef768a1264da6565d050a5e55c20977ad27cbd9a844cbe
BLAKE2b-256 checksum
How to use checksums
22e1f8b803c77c6bef82842459a55855c0d04a98e7fc01f9a3b2e303dac0311a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for function-diff 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page