Make package re-exports explicit with __all__#623
Conversation
|
@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. |
📝 WalkthroughWalkthroughPackage 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. ChangesPackage export contract
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🧪 PR Test Results
Python 3.12 · commit 3b08a47 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pyproject.toml (1)
127-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueF405 addition is correct; consider removing the redundant glob pattern.
Adding
F405to both per-file-ignore entries is the right call —__all__references names brought in viafrom .sub import *, so Ruff needsF405suppressed in these initializers. As per coding guidelines,agentwatch/**/__init__.pyfiles use wildcard re-exports and suppressF401/F403rules per-file;F405is a natural extension.The
agentwatch/**/__init__.pypattern (with**) matches__init__.pyfiles at any depth, making theagentwatch/*/__init__.pypattern (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
📒 Files selected for processing (15)
agentwatch/adapters/__init__.pyagentwatch/alerting/__init__.pyagentwatch/core/__init__.pyagentwatch/cost/__init__.pyagentwatch/governance/__init__.pyagentwatch/memory/__init__.pyagentwatch/orchestration/__init__.pyagentwatch/plugins/__init__.pyagentwatch/reasoning/__init__.pyagentwatch/replay/__init__.pyagentwatch/rollback/__init__.pyagentwatch/scoring/__init__.pyagentwatch/tracing/__init__.pypyproject.tomltests/test_package_exports.py
Thirteen package
__init__files dofrom .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 narrowsimport *, 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, andimport *yields exactly__all__.Summary by CodeRabbit
Refactor
Tests
Chores