feat(sdk): add Python fluent API facade, update README, and bump to 0.2.0#161
feat(sdk): add Python fluent API facade, update README, and bump to 0.2.0#161
Conversation
Add Envilder facade with one-liner and fluent builder patterns:
- Envilder.load('map.json') — resolve + inject into os.environ
- Envilder.resolve_file('map.json') — resolve to dict
- Envilder.from_file('map.json').with_provider(...).resolve()
- Envilder.from_file('map.json').with_profile(...).inject()
Existing EnvilderClient/MapFileParser/SecretProviderFactory unchanged.
8 new tests covering resolve, inject, overrides, and validation.
WalkthroughIntroduces a new Changes
Sequence DiagramsequenceDiagram
participant Client
participant Envilder
participant MapFileParser
participant SecretProviderFactory
participant EnvilderClient
participant Environment
Client->>Envilder: load('secrets-map.json')
Envilder->>MapFileParser: parse JSON file
MapFileParser-->>Envilder: map_file dict
Envilder->>SecretProviderFactory: create(options)
SecretProviderFactory-->>Envilder: secret_provider
Envilder->>EnvilderClient: resolve_secrets(map_file)
EnvilderClient-->>Envilder: secrets dict
Envilder->>EnvilderClient: inject_into_environment(secrets)
EnvilderClient->>Environment: os.environ.update()
Envilder-->>Client: secrets dict
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
1f91838 to
d2aff13
Compare
b3da938 to
9900374
Compare
9900374 to
4f5389b
Compare
4f5389b to
f48dfed
Compare
- Use Path(__file__) for MAP_FILE in test_envilder.py so tests pass regardless of working directory (fixes CI cd+pytest) - Auto-format coverage-report scripts with Biome (single quotes, trailing newline)
- Add radix parameter (10) to parseInt calls - Suppress noControlCharactersInRegex for intentional ANSI stripping
- Add encoding='utf-8' to open() in envilder_facade._parse_file - Replace backslash line continuations with parentheses in README - Add missing import in 'Resolve without injecting' README snippet - Use context manager in 'Advanced usage' README snippet - Merge implicit string concatenations into single strings - Rename test_envilder.py to test_envilder_facade.py (mirror convention)
There was a problem hiding this comment.
♻️ Duplicate comments (1)
tests/sdks/python/application/test_envilder_facade.py (1)
143-157:⚠️ Potential issue | 🟡 MinorRemove lambda assignments in validation tests (E731).
Line 143 and Line 153 assign lambdas to
action; this is a Ruff E731 violation and can fail lint checks. Call the functions directly insidepytest.raises().♻️ Suggested fix
- # Act - action = lambda: Envilder.load("non-existent.json") - - # Assert - with pytest.raises(FileNotFoundError): - action() + # Act / Assert + with pytest.raises(FileNotFoundError): + Envilder.load("non-existent.json") @@ - # Act - action = lambda: Envilder.from_file("") - - # Assert - with pytest.raises(ValueError, match="file_path"): - action() + # Act / Assert + with pytest.raises(ValueError, match="file_path"): + Envilder.from_file("")#!/bin/bash # Verify lambda assignments used for pytest "action" wrappers in this module. rg -nP --type=py '^\s*action\s*=\s*lambda\b' tests/sdks/python/application/test_envilder_facade.py -C2🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/sdks/python/application/test_envilder_facade.py` around lines 143 - 157, The tests assign lambdas to `action` (Ruff E731) before using `pytest.raises`; replace those lambda assignments by calling the target functions directly inside the context manager — e.g., change `action = lambda: Envilder.load("non-existent.json"); with pytest.raises(FileNotFoundError): action()` to `with pytest.raises(FileNotFoundError): Envilder.load("non-existent.json")`, and similarly replace `action = lambda: Envilder.from_file("")`/`with pytest.raises(ValueError, match="file_path"): action()` with `with pytest.raises(ValueError, match="file_path"): Envilder.from_file("")` so `Envilder.load` and `Envilder.from_file` are invoked directly in the `pytest.raises` block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@tests/sdks/python/application/test_envilder_facade.py`:
- Around line 143-157: The tests assign lambdas to `action` (Ruff E731) before
using `pytest.raises`; replace those lambda assignments by calling the target
functions directly inside the context manager — e.g., change `action = lambda:
Envilder.load("non-existent.json"); with pytest.raises(FileNotFoundError):
action()` to `with pytest.raises(FileNotFoundError):
Envilder.load("non-existent.json")`, and similarly replace `action = lambda:
Envilder.from_file("")`/`with pytest.raises(ValueError, match="file_path"):
action()` with `with pytest.raises(ValueError, match="file_path"):
Envilder.from_file("")` so `Envilder.load` and `Envilder.from_file` are invoked
directly in the `pytest.raises` block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6d250bfe-b41c-42cf-b3bf-fdc1c76b0e24
⛔ Files ignored due to path filters (2)
.github/workflows/coverage-report/extract-test-stats.mjsis excluded by none and included by none.github/workflows/coverage-report/generate-coverage-dashboard.mjsis excluded by none and included by none
📒 Files selected for processing (5)
src/sdks/python/README.mdsrc/sdks/python/envilder/application/envilder_facade.pysrc/sdks/python/envilder/infrastructure/secret_provider_factory.pytests/sdks/python/application/test_envilder_facade.pytests/sdks/python/containers/localstack_container.py
✅ Files skipped from review due to trivial changes (3)
- tests/sdks/python/containers/localstack_container.py
- src/sdks/python/envilder/infrastructure/secret_provider_factory.py
- src/sdks/python/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
- src/sdks/python/envilder/application/envilder_facade.py
Summary
Introduces the
Envilderfacade class for the Python SDK, providing one-linerand fluent builder APIs for secret resolution. Updates the README with usage
examples, adds badges, and bumps the package version to 0.2.0.
Changes
New:
Envilderfacade (envilder_facade.py)Envilder.load(file)— resolve + inject intoos.environin one callEnvilder.resolve_file(file)— resolve without injectingEnvilder.from_file(file).with_provider(...).with_vault_url(...).resolve()— fluent builderwith_provider(),with_vault_url(),with_profile()— runtime overrides for$configREADME
Infra / CI
0.1.0→0.2.0inpyproject.tomlMakefileformat-sdk-pythonto split black/isort per directoryparseIntradix, ANSI regex suppression)Path(__file__)instead of relative string)Code quality (from review feedback)
encoding="utf-8"toopen()in_parse_filetest_envilder.py→test_envilder_facade.py(mirror convention)Tests
Testing
make check-sdk-pythonpasses (black, isort, mypy)pytest— 42/42 passpnpm biome check— cleanRelated
Follows
feat/sdk-python-fluent-api(merged to main).