fix(utils): Preserve decorated type for @experimental and @working_in_progress#6030
Closed
Jacksunwei wants to merge 1 commit into
Closed
fix(utils): Preserve decorated type for @experimental and @working_in_progress#6030Jacksunwei wants to merge 1 commit into
Jacksunwei wants to merge 1 commit into
Conversation
…_progress The feature decorators were typed as returning Any, so any class or function decorated with @experimental (e.g. BaseEnvironment) was seen as Any by type checkers. This erased the base class, causing spurious 'no base method present' errors on every @OverRide in subclasses. Add @overload signatures so the decorators preserve the decorated object's type across all three call forms (@experimental, @experimental(), @experimental('msg')) for both classes and functions.
Collaborator
🔍 ADK Pull Request Analysis: PR #6030Title: fix(utils): Preserve decorated type for @experimental and @working_in_progress Executive Summary
Detailed Findings & Analysis1. Objectives & Impact ("What does it do?")
2. Justification & Value ("Is it a valid and useful change?")
3. Principle & Style Alignment Checklist ("Does it follow rules?")
|
4 tasks
copybara-service Bot
pushed a commit
that referenced
this pull request
Jun 9, 2026
…_progress Merge #6030 ## Summary The feature decorators (`@experimental`, `@working_in_progress`) were typed as returning `Any`, so any class or function they decorated (e.g. `BaseEnvironment`) was seen as `Any` by type checkers. This erased the base class, producing spurious `"no base method present"` errors on every `@override` in subclasses (`LocalEnvironment`, and any future subclass). This adds a `_FeatureDecorator` `Protocol` with `@overload` signatures so the decorators preserve the decorated object's type across all three call forms — `@experimental`, `@experimental()`, `@experimental("msg")` — for both classes and functions. ## Impact - `BaseEnvironment` now resolves as `type[BaseEnvironment]` instead of `Any`. - `LocalEnvironment`'s 6 spurious `@override` errors drop to 0 (verified with pyright). - Runtime behavior is unchanged: warnings still fire, class names and callability are preserved. ## Test plan - [x] `pytest tests/unittests/utils/test_feature_decorator.py` (17 passed) - [x] `pytest tests/unittests/features/test_feature_decorator.py` (11 passed) - [x] `pyright src/google/adk/utils/feature_decorator.py` — 0 errors - [x] Verified `LocalEnvironment` override errors went 6 → 0 Co-authored-by: Wei Sun (Jack) <weisun@google.com> COPYBARA_INTEGRATE_REVIEW=#6030 from google:fix/experimental-typing 5bdb8a4 PiperOrigin-RevId: 929281312
Collaborator
|
Thank you @Jacksunwei for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 1ff0158. Closing this PR as the changes are now in the main branch. |
copybara-service Bot
pushed a commit
that referenced
this pull request
Jun 9, 2026
…_progress Merge #6030 ## Summary The feature decorators (`@experimental`, `@working_in_progress`) were typed as returning `Any`, so any class or function they decorated (e.g. `BaseEnvironment`) was seen as `Any` by type checkers. This erased the base class, producing spurious `"no base method present"` errors on every `@override` in subclasses (`LocalEnvironment`, and any future subclass). This adds a `_FeatureDecorator` `Protocol` with `@overload` signatures so the decorators preserve the decorated object's type across all three call forms — `@experimental`, `@experimental()`, `@experimental("msg")` — for both classes and functions. ## Impact - `BaseEnvironment` now resolves as `type[BaseEnvironment]` instead of `Any`. - `LocalEnvironment`'s 6 spurious `@override` errors drop to 0 (verified with pyright). - Runtime behavior is unchanged: warnings still fire, class names and callability are preserved. ## Test plan - [x] `pytest tests/unittests/utils/test_feature_decorator.py` (17 passed) - [x] `pytest tests/unittests/features/test_feature_decorator.py` (11 passed) - [x] `pyright src/google/adk/utils/feature_decorator.py` — 0 errors - [x] Verified `LocalEnvironment` override errors went 6 → 0 PiperOrigin-RevId: 929389871
copybara-service Bot
pushed a commit
that referenced
this pull request
Jun 9, 2026
Merge #6031 > **Stacked on #6030** (`fix/experimental-typing`). This PR targets that branch; please review/merge #6030 first, after which this will be retargeted to `main`. ## Summary Adds `E2BEnvironment`, a `BaseEnvironment` backed by an [E2B](https://e2b.dev) sandbox. It gives agents a persistent remote workspace for shell execution, file CRUD, and on-demand installs (`pip`/`apt`) without touching the host machine. - The sandbox TTL is bounded to cap credit usage and is extended on each operation; an expired idle sandbox is transparently recreated. - Lazy-imports the SDK behind a new `e2b` extra, so the base package stays lean. - Includes a data-analysis sample that downloads a public (GCS-hosted) dataset and analyzes it inside the sandbox. ## Usage ```python from google.adk.integrations.e2b import E2BEnvironment from google.adk.tools.environment import EnvironmentToolset toolset = EnvironmentToolset(environment=E2BEnvironment()) ``` ## Test plan - [x] `pytest tests/unittests/integrations/e2b/` (14 passed) - [x] `pyright src/google/adk/integrations/e2b/_e2b_environment.py` — 0 errors - [x] Sample agent loads (`contributing/samples/environment_and_skills/e2b_environment`) - [ ] Manual run against a live E2B sandbox (requires `E2B_API_KEY`) Co-authored-by: Wei Sun (Jack) <weisun@google.com> COPYBARA_INTEGRATE_REVIEW=#6031 from google:feat/e2b f2b5584 PiperOrigin-RevId: 929443164
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The feature decorators (
@experimental,@working_in_progress) were typed as returningAny, so any class or function they decorated (e.g.BaseEnvironment) was seen asAnyby type checkers. This erased the base class, producing spurious"no base method present"errors on every@overridein subclasses (LocalEnvironment, and any future subclass).This adds a
_FeatureDecoratorProtocolwith@overloadsignatures so the decorators preserve the decorated object's type across all three call forms —@experimental,@experimental(),@experimental("msg")— for both classes and functions.Impact
BaseEnvironmentnow resolves astype[BaseEnvironment]instead ofAny.LocalEnvironment's 6 spurious@overrideerrors drop to 0 (verified with pyright).Test plan
pytest tests/unittests/utils/test_feature_decorator.py(17 passed)pytest tests/unittests/features/test_feature_decorator.py(11 passed)pyright src/google/adk/utils/feature_decorator.py— 0 errorsLocalEnvironmentoverride errors went 6 → 0