Skip to content

Make Suite.append() chainable (return self)#2317

Merged
kevinmessiaen merged 4 commits intoGiskard-AI:mainfrom
Bingtagui404:fix/suite-append-chainable
Mar 19, 2026
Merged

Make Suite.append() chainable (return self)#2317
kevinmessiaen merged 4 commits intoGiskard-AI:mainfrom
Bingtagui404:fix/suite-append-chainable

Conversation

@Bingtagui404
Copy link
Copy Markdown
Contributor

Description

Make Suite.append() return self (typed as Self) so it supports fluent chaining like suite.append(a).append(b). This aligns with the existing fluent API pattern used throughout the codebase (e.g. Scenario.interact().check()).

Related Issue

Fixes #2315

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Reproduction

suite = Suite(name="test")
suite.append(scenario_a).append(scenario_b)
# AttributeError: 'NoneType' object has no attribute 'append'

Fix Scope

  • libs/giskard-checks/src/giskard/checks/scenarios/suite.py: Changed append() return type from None to Self and added return self. Updated docstring (numpydoc Returns section + examples).
  • libs/giskard-checks/tests/core/test_suite.py: Added test_suite_append_returns_self and test_suite_append_chaining regression tests.

Test Evidence

Two new tests added:

  1. test_suite_append_returns_self — asserts suite.append(a) is suite
  2. test_suite_append_chaining — chains .append(a).append(b), verifies len(suite.scenarios) == 2 and suite.run() completes successfully.

Known Limitations

None. The change is fully backward-compatible — existing code that ignores the return value of append() is unaffected.

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've written tests for all new methods and classes that I created.
  • I've written the docstring in numpydoc format for all the methods and classes that I used.
  • I've updated the pdm.lock running pdm update-lock (only applicable when pyproject.toml has been modified)

Bingtagui404 added 2 commits March 19, 2026 14:30
Suite.append() 原本返回 None,无法链式调用如 suite.append(a).append(b)。
改为返回 self 并更新类型标注和 docstring。

Fixes Giskard-AI#2315
根据 Codex 审查反馈:
- 返回类型从 "Suite[InputType, OutputType]" 改为 Self,与 Scenario 等同包 fluent API 保持一致
- 新增 test_suite_append_returns_self 和 test_suite_append_chaining 两个测试用例
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Suite class by making its append method chainable. This change allows for more concise and readable code when adding multiple scenarios to a suite, aligning with existing fluent API patterns within the codebase. The modification is fully backward-compatible and includes updated type hints, documentation, and comprehensive test coverage.

Highlights

  • Fluent API: The Suite.append() method was updated to return self, enabling fluent chaining of append() calls.
  • Type Hinting: The return type annotation for Suite.append() was changed from None to Self to accurately reflect its new behavior.
  • Documentation and Examples: The docstring for Suite.append() was updated to include a 'Returns' section, and existing code examples were modified to demonstrate the new chaining capability.
  • Testing: Two new regression tests, test_suite_append_returns_self and test_suite_append_chaining, were added to verify the correct return value and functionality of chained append() calls.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request makes the Suite.append() method chainable by having it return self. The change is well-implemented, follows the fluent API pattern seen elsewhere in the codebase, and is accompanied by new tests. My only suggestion is to enhance one of the new tests to be more specific about what it verifies, ensuring the scenarios are appended in the correct order.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Member

@kevinmessiaen kevinmessiaen left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Looking good

@kevinmessiaen kevinmessiaen enabled auto-merge (squash) March 19, 2026 09:55
@kevinmessiaen kevinmessiaen disabled auto-merge March 19, 2026 09:55
@kevinmessiaen kevinmessiaen merged commit 881024b into Giskard-AI:main Mar 19, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Make Suite.append() chainable (fluent suite builder)

2 participants