Skip to content

Make package re-exports explicit with __all__#623

Open
pavsoss wants to merge 1 commit into
sreerevanth:mainfrom
pavsoss:chore/package-all-exports
Open

Make package re-exports explicit with __all__#623
pavsoss wants to merge 1 commit into
sreerevanth:mainfrom
pavsoss:chore/package-all-exports

Conversation

@pavsoss

@pavsoss pavsoss commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thirteen package __init__ files do from .sub import * without an __all__, so the public API is whatever the submodules happen to define today and star-imports leak submodule internals (os, json, typing helpers).

Add an explicit __all__ to each, listing the genuine public surface (submodule __all__ where declared, otherwise real public classes/functions/constants). The wildcards stay for compatibility, __all__ only narrows import *, and direct imports are unaffected. Also ignore F405 in package __init__ files, where names intentionally resolve through the wildcards.

Tests: each package declares a non-empty __all__, every listed name resolves, no duplicates, and import * yields exactly __all__.

Summary by CodeRabbit

  • Refactor

    • Standardized and clarified the public APIs exposed by package modules.
    • Improved consistency for wildcard imports across adapters, monitoring, governance, memory, orchestration, replay, rollback, scoring, tracing, and related features.
  • Tests

    • Added automated checks to verify that public exports are defined, valid, unique, and consistent with wildcard imports.
  • Chores

    • Updated linting configuration to support the package export declarations.

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

@pavsoss is attempting to deploy a commit to the sreerevanth's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Package initializers now explicitly declare their public exports across AgentWatch modules. Ruff configuration accommodates wildcard re-exports, and new parameterized tests verify export-list validity, name resolution, uniqueness, and star-import behavior.

Changes

Package export contract

Layer / File(s) Summary
Package export declarations
agentwatch/*/__init__.py, agentwatch/adapters/__init__.py
Explicit __all__ lists define the public symbols exported by AgentWatch subpackages.
Export validation and lint configuration
pyproject.toml, tests/test_package_exports.py
Ruff ignores wildcard-import name resolution in package initializers, while parameterized tests validate export declarations and star imports.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: sreerevanth

Poem

I hopped through packages, tidy and bright,
Naming each export just right.
Ruff watched the wild imports flee,
Tests checked the list as carefully as me.
“Public APIs!” squeaked this bunny with glee.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding explicit all exports to package re-exports.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 PR Test Results

Check Result
Tests (pytest tests/) ✅ success
Lint (ruff check .) ❌ failure
Coverage (agentwatch) 74.81%

Python 3.12 · commit 3b08a47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pyproject.toml (1)

127-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

F405 addition is correct; consider removing the redundant glob pattern.

Adding F405 to both per-file-ignore entries is the right call — __all__ references names brought in via from .sub import *, so Ruff needs F405 suppressed in these initializers. As per coding guidelines, agentwatch/**/__init__.py files use wildcard re-exports and suppress F401/F403 rules per-file; F405 is a natural extension.

The agentwatch/**/__init__.py pattern (with **) matches __init__.py files at any depth, making the agentwatch/*/__init__.py pattern (with *) redundant. This predates the PR but is worth cleaning up while touching these lines.

♻️ Optional: remove redundant glob pattern
 # (F405: __all__ names resolve through those wildcards).
 "agentwatch/**/__init__.py" = ["F401", "F403", "F405"]
-"agentwatch/*/__init__.py"  = ["F401", "F403", "F405"]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pyproject.toml` around lines 127 - 129, Remove the redundant
"agentwatch/*/__init__.py" per-file-ignore entry from the Ruff configuration,
keeping "agentwatch/**/__init__.py" with F401, F403, and F405 unchanged so all
initializer files at any depth retain the required suppressions.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pyproject.toml`:
- Around line 127-129: Remove the redundant "agentwatch/*/__init__.py"
per-file-ignore entry from the Ruff configuration, keeping
"agentwatch/**/__init__.py" with F401, F403, and F405 unchanged so all
initializer files at any depth retain the required suppressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9477c6e6-56dd-4bf3-ac95-2c6c5dbe55eb

📥 Commits

Reviewing files that changed from the base of the PR and between a41220d and 3b08a47.

📒 Files selected for processing (15)
  • agentwatch/adapters/__init__.py
  • agentwatch/alerting/__init__.py
  • agentwatch/core/__init__.py
  • agentwatch/cost/__init__.py
  • agentwatch/governance/__init__.py
  • agentwatch/memory/__init__.py
  • agentwatch/orchestration/__init__.py
  • agentwatch/plugins/__init__.py
  • agentwatch/reasoning/__init__.py
  • agentwatch/replay/__init__.py
  • agentwatch/rollback/__init__.py
  • agentwatch/scoring/__init__.py
  • agentwatch/tracing/__init__.py
  • pyproject.toml
  • tests/test_package_exports.py

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