Skip to content

[IQE-3809] Update default for ibutsu source#102

Merged
mshriver merged 1 commit intoibutsu:mainfrom
akhil-jha:add_env_source_support
Feb 23, 2026
Merged

[IQE-3809] Update default for ibutsu source#102
mshriver merged 1 commit intoibutsu:mainfrom
akhil-jha:add_env_source_support

Conversation

@akhil-jha
Copy link

@akhil-jha akhil-jha commented Feb 23, 2026

Summary by Sourcery

Adjust ibutsu source configuration defaults and document their behavior.

Enhancements:

  • Change the --ibutsu-source CLI option to default to None and clarify help text to describe resolution via IBUTSU_SOURCE or 'local'.

Tests:

  • Add tests verifying ibutsu_source defaults to 'local' when unset and is taken from the IBUTSU_SOURCE environment variable when the CLI option is not provided.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 23, 2026

Reviewer's Guide

Adjusts the default handling of the ibutsu source CLI option so that the effective default comes from the IBUTSU_SOURCE environment variable or falls back to 'local', and adds tests to validate this behavior.

Sequence diagram for resolving ibutsu_source default

sequenceDiagram
    actor User
    participant Pytest as PytestRunner
    participant Plugin as PytestIbutsuPlugin
    participant Env as Environment

    User->>Pytest: run pytest (no --ibutsu-source)
    Pytest->>Plugin: call pytest_addoption(parser)
    Plugin->>Env: read IBUTSU_SOURCE
    alt IBUTSU_SOURCE is set
        Env-->>Plugin: value from IBUTSU_SOURCE
        Plugin-->>Pytest: register ibutsu_source option (default = env value)
    else IBUTSU_SOURCE is not set
        Env-->>Plugin: null
        Plugin-->>Pytest: register ibutsu_source option (default = local)
    end
    Pytest-->>User: execute tests with resolved ibutsu_source
Loading

Flow diagram for ibutsu_source default resolution

flowchart TD
    A[Start pytest] --> B{--ibutsu-source provided?}
    B -->|Yes| C[Use CLI ibutsu_source value]
    B -->|No| D{IBUTSU_SOURCE env set?}
    D -->|Yes| E[Use IBUTSU_SOURCE env value]
    D -->|No| F[Use local as default]
    C --> G[Run tests]
    E --> G
    F --> G
    G --> H[End]
Loading

File-Level Changes

Change Details Files
Change ibutsu_source CLI option to have a None default and document new default resolution behavior.
  • Update pytest_addoption configuration for --ibutsu-source so its default is None instead of 'local'.
  • Clarify help text to explain that the effective default is IBUTSU_SOURCE env or 'local'.
src/pytest_ibutsu/pytest_plugin.py
Add tests to validate ibutsu_source default resolution from environment variables and fallback behavior.
  • Add test ensuring ibutsu_source is 'local' when neither --ibutsu-source nor IBUTSU_SOURCE is set.
  • Add test ensuring IBUTSU_SOURCE environment variable is used when --ibutsu-source is not passed.
tests/test_plugin.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider handling the case where IBUTSU_SOURCE is set to an empty string so that the plugin still falls back to the 'local' default rather than treating an empty value as a valid source.
  • It may be clearer to centralize the ibutsu_source resolution logic (CLI arg vs env vs 'local') into a small helper function, so the precedence rules are encapsulated and easier to adjust in the future.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider handling the case where IBUTSU_SOURCE is set to an empty string so that the plugin still falls back to the 'local' default rather than treating an empty value as a valid source.
- It may be clearer to centralize the ibutsu_source resolution logic (CLI arg vs env vs 'local') into a small helper function, so the precedence rules are encapsulated and easier to adjust in the future.

## Individual Comments

### Comment 1
<location> `tests/test_plugin.py:116-124` </location>
<code_context>
     IbutsuPlugin.from_config(test_config)


+def test_ibutsu_source_default_when_unset(
+    isolate_ibutsu_env_vars: None, pytester: pytest.Pytester
+):
+    """Test ibutsu_source is 'local' when neither --ibutsu-source nor IBUTSU_SOURCE is set."""
+    test_config = pytester.parseconfig(
+        "--ibutsu", "archive", "--ibutsu-project", "test-project"
+    )
+    plugin = IbutsuPlugin.from_config(test_config)
+    assert plugin.ibutsu_source == "local"
+
+
</code_context>

<issue_to_address>
**suggestion (testing):** Add a test for precedence when both CLI and IBUTSU_SOURCE are set

To complete coverage, please add a case where both `--ibutsu-source` and `IBUTSU_SOURCE` are set, asserting that the CLI option takes precedence over the env var. This will lock in the intended precedence behavior and protect against regressions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.15%. Comparing base (a7912eb) to head (edd73c1).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (68.15%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #102   +/-   ##
=======================================
  Coverage   68.15%   68.15%           
=======================================
  Files           7        7           
  Lines         829      829           
  Branches      140      140           
=======================================
  Hits          565      565           
  Misses        235      235           
  Partials       29       29           
Flag Coverage Δ
unittests 68.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/pytest_ibutsu/pytest_plugin.py 67.71% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7912eb...edd73c1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akhil-jha akhil-jha force-pushed the add_env_source_support branch from 35eb016 to edd73c1 Compare February 23, 2026 07:03
@mshriver mshriver merged commit 4086c24 into ibutsu:main Feb 23, 2026
7 of 8 checks passed
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.

2 participants