Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(cli): make test imports lazy so secrets command works without [dev] extra#900

Merged
Aaron ("AJ") Steers (aaronsteers) merged 3 commits intomainfrom
devin/1770399442-secrets-without-dev
Feb 6, 2026
Merged

fix(cli): make test imports lazy so secrets command works without [dev] extra#900
Aaron ("AJ") Steers (aaronsteers) merged 3 commits intomainfrom
devin/1770399442-secrets-without-dev

Conversation

@aaronsteers
Copy link
Contributor

@aaronsteers Aaron ("AJ") Steers (aaronsteers) commented Feb 6, 2026

Summary

Moves the create_connector_test_suite import in _connector.py from module-level to inside run_connector_tests(), making it lazy. This fixes uvx airbyte-cdk secrets list ... (and all other CLI commands) failing with ModuleNotFoundError: No module named 'pytest' when the [dev] extra is not installed.

Root cause: __init__.py eagerly imports _connector.py, which eagerly imports create_connector_test_suite from test.standard_tests.util, which transitively imports docker_base.py, which does a hard import pytest. This breaks the entire CLI—not just connector test—when pytest isn't installed.

The import is placed after the existing pytest is None guard, so users still get a clean error if they run connector test without pytest.

Review & Testing Checklist for Human

  • Verify uvx airbyte-cdk secrets list <connector> works without [dev] (can test locally: pip install airbyte-cdk in a clean venv, then run airbyte-cdk secrets list source-postgres)
  • Verify airbyte-cdk connector test still works when pytest IS installed (e.g. in a dev environment with [dev] extra)

Notes


Open with Devin

Summary by CodeRabbit

  • Chores
    • Optimized dependency loading to improve performance during test execution.

Copilot AI review requested due to automatic review settings February 6, 2026 17:39
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Makes the CLI resilient when optional dev-only test dependencies (e.g., pytest) are not installed by deferring the test-suite import until tests are actually executed.

Changes:

  • Removes the module-level import of create_connector_test_suite to prevent eager import chains on CLI startup.
  • Reintroduces the import inside run_connector_tests() after the existing pytest presence guard.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

Testing This CDK Version

You can test this version of the CDK using the following:

# Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1770399442-secrets-without-dev#egg=airbyte-python-cdk[dev]' --help

# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1770399442-secrets-without-dev

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poetry-lock - Updates poetry.lock file
  • /test - Runs connector tests with the updated CDK
  • /prerelease - Triggers a prerelease publish with default arguments
  • /poe build - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
  • /poe <command> - Runs any poe command in the CDK environment
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

The change introduces lazy loading by moving the create_connector_test_suite import from module scope into the run_connector_tests function, deferring dependency resolution until tests are actually executed rather than at module import time.

Changes

Cohort / File(s) Summary
Lazy Import Refactoring
airbyte_cdk/cli/airbyte_cdk/_connector.py
Relocated create_connector_test_suite import from top-level to function scope within run_connector_tests, adding an explanatory comment for the lazy-loading pattern.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly and specifically describes the main change: making test imports lazy to allow the secrets command to work without the [dev] extra dependency.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1770399442-secrets-without-dev

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.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

PyTest Results (Fast)

3 855 tests  ±0   3 843 ✅ ±0   6m 7s ⏱️ -20s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit b588ded. ± Comparison against base commit 57c70ba.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

PyTest Results (Full)

3 858 tests  ±0   3 846 ✅ ±0   10m 52s ⏱️ -14s
    1 suites ±0      12 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit b588ded. ± Comparison against base commit 57c70ba.

@aaronsteers Aaron ("AJ") Steers (aaronsteers) merged commit 15fdf5a into main Feb 6, 2026
29 checks passed
@aaronsteers Aaron ("AJ") Steers (aaronsteers) deleted the devin/1770399442-secrets-without-dev branch February 6, 2026 18:14
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