Skip to content

fix(policy_endpoints): re-export private helper functions from package __init__.py#21667

Merged
jquinter merged 1 commit intomainfrom
fix/policy-endpoints-export-private-helpers
Feb 20, 2026
Merged

fix(policy_endpoints): re-export private helper functions from package __init__.py#21667
jquinter merged 1 commit intomainfrom
fix/policy-endpoints-export-private-helpers

Conversation

@jquinter
Copy link
Contributor

Summary

  • test_policy_endpoints.py was failing at collection with:
    ImportError: cannot import name '_build_all_names_per_competitor' from 'litellm.proxy.management_endpoints.policy_endpoints'
    
  • Root cause: Python's import * does not re-export names beginning with _. The __init__.py only used from .endpoints import *, so the 8 private competitor-enrichment helper functions were invisible at the package level.
  • Fix: Added an explicit import block for all 8 private helpers so they are accessible from the package namespace.

Not related to PR #21664 (pricing JSON changes).

Test plan

  • pytest tests/test_litellm/proxy/management_endpoints/test_policy_endpoints.py --collect-only now collects 43 tests (previously import error)

🤖 Generated with Claude Code

…from __init__.py

`import *` does not re-export names starting with `_`, so the private
competitor-enrichment helpers added in endpoints.py were invisible when
imported from the package:

  from litellm.proxy.management_endpoints.policy_endpoints import (
      _build_all_names_per_competitor, ...
  )

This caused an ImportError that prevented the entire test module from
collecting. Add explicit imports for each private helper so they are
accessible from the package namespace.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 20, 2026 2:11pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Greptile Summary

Fixes import error in test_policy_endpoints.py by explicitly re-exporting 8 private helper functions from the package __init__.py.

  • Root cause: Python's import * doesn't re-export names starting with _, so the test file's import of private functions like _build_all_names_per_competitor failed
  • Solution: Added explicit import block for all 8 helper functions (_build_all_names_per_competitor, _build_comparison_blocked_words, _build_competitor_guardrail_definitions, _build_name_blocked_words, _build_recommendation_blocked_words, _build_refinement_prompt, _clean_competitor_line, _parse_variations_response)
  • Verification: All 8 functions exist in endpoints.py and match the imports in the test file at lines 595-604
  • Evidence: PR description states test collection now works (43 tests collected vs. previous ImportError)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix correctly addresses a Python import visibility issue by explicitly re-exporting 8 private helper functions that were previously hidden by import *. All 8 functions exist in endpoints.py and match the test imports. The change is minimal, well-documented, and the PR description includes evidence of the fix (test collection now works).
  • No files require special attention

Important Files Changed

Filename Overview
litellm/proxy/management_endpoints/policy_endpoints/init.py Explicitly re-exports 8 private helper functions to fix test imports - straightforward fix

Last reviewed commit: 65388d8

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jquinter jquinter merged commit 39d95eb into main Feb 20, 2026
20 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant