Deduplicate DatabaseJanitor codebase after async introduction#1364
Deduplicate DatabaseJanitor codebase after async introduction#1364fizyk wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe janitor module now centralises shared configuration and ChangesDatabaseJanitor deduplication
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pytest_postgresql/janitor.py (1)
25-26: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsolidate
is_templateintoBaseDatabaseJanitor.Since this PR focuses on deduplication and
as_templateis already managed inBaseDatabaseJanitor, you can further reduce duplication by moving theis_templatemethod to the base class and removing it from both subclasses.♻️ Proposed refactor
class BaseDatabaseJanitor: """Common base class for database janitors.""" + + def is_template(self) -> bool: + """Determine whether the janitor maintains template or database.""" + return self.as_templateThen, remove
is_templatefrom bothDatabaseJanitorandAsyncDatabaseJanitor:# Remove from DatabaseJanitor: def is_template(self) -> bool: """Determine whether the DatabaseJanitor maintains template or database.""" return self.as_template # Remove from AsyncDatabaseJanitor: def is_template(self) -> bool: """Determine whether the AsyncDatabaseJanitor maintains template or database.""" return self.as_template🤖 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 `@pytest_postgresql/janitor.py` around lines 25 - 26, Move the is_template method into BaseDatabaseJanitor, returning the existing as_template state, and remove the duplicate implementations from DatabaseJanitor and AsyncDatabaseJanitor. Preserve the current method signature and behavior for both subclasses through inheritance.
🤖 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 `@pytest_postgresql/janitor.py`:
- Around line 25-26: Move the is_template method into BaseDatabaseJanitor,
returning the existing as_template state, and remove the duplicate
implementations from DatabaseJanitor and AsyncDatabaseJanitor. Preserve the
current method signature and behavior for both subclasses through inheritance.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e749333d-3cd4-4bd7-86d3-bd1bb4be9179
📒 Files selected for processing (2)
newsfragments/+55f953a1.misc.rstpytest_postgresql/janitor.py
Summary by CodeRabbit
Refactor
Documentation