Skip to main content

Git-aware checker for globally unique Python function names + reuse suggestions for AI agents

Project description

uniqfunc

A git-aware checker for AI-generated Python code that enforces repo-wide unique function names (blocking) and emits reuse candidates for agent review (non-blocking).

Recommended agent loop (Codex)

  1. Generate or modify code.
  2. Run uvx uniqfunc --format json.
  3. If exit code 1, fix naming conflicts until clean.
  4. If reuse_suggestions are present, consider reusing or refactoring existing functions.

VS Code integration

Text output is VS Code-clickable because every diagnostic line begins with path:line:col (no leading spaces).

Usage

uvx uniqfunc

Defaults ignore main and cli. Add more exclude patterns (repeatable regex):

uvx uniqfunc --exclude-name '^main$' --exclude-name '^cli$'

Output examples

Text (duplicate):

path/to/file.py:10:1 UQF100 duplicate function name 'foo' (also in other.py:42:1) signature=def foo(): also_signature=def foo():

Text (reuse suggestions):

=== UNIQFUNC LLM REUSE SUGGESTIONS ===
src/timeutils.py:12:1 UQF200 reuse_candidate target=epoch_to_aware_datetime candidates=1 signature=def epoch_to_aware_datetime(epoch_seconds) -> datetime:
src/timeutils.py:5:1 UQF201 candidate_for=epoch_to_aware_datetime target_loc=src/timeutils.py:12:1 name=epoch_to_datetime score=0.83 signals=name_token_jaccard:0.66 signature:0.75 ast:0.90 signature=def epoch_to_datetime(epoch) -> datetime:
=== END UNIQFUNC LLM REUSE SUGGESTIONS ===

JSON:

{
  "version": "0.1.3",
  "repo_root": "/abs/path",
  "naming_conflicts": [
    {
      "code": "UQF100",
      "name": "foo",
      "occurrence": {"path": "a.py", "line": 10, "col": 1},
      "first_seen": {"path": "b.py", "line": 42, "col": 1}
    }
  ],
  "reuse_suggestions": [
    {
      "target": {"path": "timeutils.py", "line": 12, "col": 1, "name": "epoch_to_aware_datetime"},
      "candidates": [
        {
          "path": "timeutils.py",
          "line": 5,
          "col": 1,
          "name": "epoch_to_datetime",
          "score": 0.83,
          "signals": {
            "name_token_jaccard": 0.66,
            "signature_score": 0.75,
            "ast_score": 0.90
          }
        }
      ]
    }
  ],
  "errors": []
}

Notes

  • Requires a git repo and uses git ls-files for file selection.
  • No config by design.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uniqfunc-0.1.3.tar.gz (571.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uniqfunc-0.1.3-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file uniqfunc-0.1.3.tar.gz.

File metadata

  • Download URL: uniqfunc-0.1.3.tar.gz
  • Upload date:
  • Size: 571.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for uniqfunc-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0007be4f86bb1caabd7d0b4303b63b8153e3357103e38a62a14c55d636794914
MD5 6fed13683080b1acea1e909874bc5a37
BLAKE2b-256 e8af07ef090344582786221b14b59ab3042481c36ce4cd57fe723d97e370fcd5

See more details on using hashes here.

File details

Details for the file uniqfunc-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: uniqfunc-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for uniqfunc-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cd3a0bda5342f33e64fd492ed282321dd5d15fdc920da7895d0a7bd4e7c9d026
MD5 d9193e179c0ad0eeacf7a704ac14c4f5
BLAKE2b-256 784707b4af96f49c9242c4e81bc2207070e2cc162f50f242768ffd254fd16b57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page