Skip to content

Add global getter to setup_dialogs - #525

Merged
Tishka17 merged 1 commit into
developfrom
feature/global_getter
Mar 22, 2026
Merged

Tishka17 merged 1 commit into
developfrom
feature/global_getter

Conversation

@Tishka17

@Tishka17 Tishka17 commented Mar 22, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Support for a global data getter that can be provided during setup to compute and include additional dynamic data for dialogs.
  • Documentation

    • Clarified where getter-functions may be defined: per Dialog, per Window, or globally via setup.
    • Fixed a typo in the event-handlers section.

@coderabbitai

coderabbitai Bot commented Mar 22, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd720465-b765-4782-957f-9e9d6fbe68d1

📥 Commits

Reviewing files that changed from the base of the PR and between 3441ab9 and 4ec8bef.

📒 Files selected for processing (4)
  • docs/widgets/passing_data/index.rst
  • src/aiogram_dialog/manager/manager.py
  • src/aiogram_dialog/manager/manager_factory.py
  • src/aiogram_dialog/setup.py
✅ Files skipped from review due to trivial changes (1)
  • docs/widgets/passing_data/index.rst
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/aiogram_dialog/manager/manager.py
  • src/aiogram_dialog/manager/manager_factory.py
  • src/aiogram_dialog/setup.py

📝 Walkthrough

Walkthrough

Adds an optional DataGetter that can be passed into setup_dialogs, propagated through the manager factory into ManagerImpl, and conditionally invoked during load_data() to merge computed fields into the dialog payload.

Changes

Cohort / File(s) Summary
Documentation
docs/widgets/passing_data/index.rst
Broadened where getter-functions may be defined (Dialog, Window, or globally in setup_dialogs); fixed typo "acess" → "access".
Manager Implementation
src/aiogram_dialog/manager/manager.py
ManagerImpl.__init__ accepts `getter: DataGetter
Manager Factory
src/aiogram_dialog/manager/manager_factory.py
DefaultManagerFactory.__init__ accepts and stores `getter: DataGetter
Setup Configuration
src/aiogram_dialog/setup.py
setup_dialogs() and _prepare_dialog_manager_factory() gain optional `getter: DataGetter

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Setup as setup_dialogs()
    participant Factory as DefaultManagerFactory
    participant Manager as ManagerImpl
    participant Getter as DataGetter
    participant Payload as Payload

    User->>Setup: call setup_dialogs(getter=...)
    Setup->>Factory: create DefaultManagerFactory(getter)
    Factory->>Manager: instantiate ManagerImpl(getter)
    Note over Manager: later, during load_data()
    Manager->>Getter: await getter(**middleware_data)
    Getter-->>Manager: return computed_fields
    Manager->>Payload: merge computed_fields into payload
    Payload-->>Manager: enriched payload returned
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A little getter hopped through the code so spry,
From setup to factory, then manager it flew,
When loading data it fetched a bright sprig of sky,
Merging new fields — a fresh, timely view.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a global getter parameter to the setup_dialogs function, which is the primary feature across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/global_getter

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 and usage tips.

Tip

CodeRabbit can use your project's `ruff` configuration to improve the quality of Python code reviews.

Add a Ruff configuration file to your project to customize how CodeRabbit runs ruff.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/aiogram_dialog/manager/manager.py`:
- Around line 81-82: ManagerImpl.__init__ currently types the parameter getter
as DataGetter but DefaultManagerFactory passes getter: DataGetter | None; change
the getter parameter and the stored attribute (self._getter) types to allow None
(DataGetter | None) so the signatures align with DefaultManagerFactory, keeping
the existing runtime None checks (e.g., the “if self._getter:” guard) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9b391a73-5042-43b1-afa2-963c0eddb4e7

📥 Commits

Reviewing files that changed from the base of the PR and between bb05af1 and 3441ab9.

📒 Files selected for processing (4)
  • docs/widgets/passing_data/index.rst
  • src/aiogram_dialog/manager/manager.py
  • src/aiogram_dialog/manager/manager_factory.py
  • src/aiogram_dialog/setup.py

Comment thread src/aiogram_dialog/manager/manager.py Resolved
@Tishka17
Tishka17 force-pushed the feature/global_getter branch from 3441ab9 to 4ec8bef Compare March 22, 2026 12:05
@Tishka17
Tishka17 merged commit a7818bd into develop Mar 22, 2026
7 checks passed
@Tishka17
Tishka17 deleted the feature/global_getter branch March 22, 2026 12:27
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