Skip to content

Commit 5ed1ff3

Browse files
committed
fix(memory): resolve 3 new mypy errors flagged by mypy-diff CI
Addresses the mypy-new-error gate failures on Python 3.10/3.13: - memory/__init__.py: add `-> Any` return annotation to the lazy `__getattr__(name)` so it satisfies `no-untyped-def`. Matches the convention used by `tools/__init__.py` and `skills/__init__.py`. - memory/_memory_schemas.py: silence SQLAlchemy's `DeclarativeBase` type-stub `Any` base-class warning (same pattern as other places where SQLAlchemy is used; pre-existing analogous errors in sessions/schemas/{v0,v1}.py are grandfathered on main). - memory/database_memory_service.py: annotate `__aexit__` parameters so mypy no longer flags `no-untyped-def`. Verified locally: * `mypy .` reports zero errors in the three new files (the mypy-diff gate compares against main; all remaining errors under `src/google/adk/memory/` are pre-existing on main). * All 19 DatabaseMemoryService unit tests still pass. * pyink --check and isort --check-only are clean.
1 parent 9490b57 commit 5ed1ff3

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/google/adk/memory/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import logging
15+
from typing import Any
1516

1617
from .base_memory_service import BaseMemoryService
1718
from .in_memory_memory_service import InMemoryMemoryService
@@ -27,7 +28,7 @@
2728
]
2829

2930

30-
def __getattr__(name: str):
31+
def __getattr__(name: str) -> Any:
3132
if name == 'DatabaseMemoryService':
3233
try:
3334
from .database_memory_service import DatabaseMemoryService

src/google/adk/memory/_memory_schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
_MAX_KEY_LENGTH = 128
3333

3434

35-
class Base(DeclarativeBase):
35+
class Base(DeclarativeBase): # type: ignore[misc]
3636
"""Base class for memory database tables."""
3737

3838
pass

src/google/adk/memory/database_memory_service.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,13 @@ async def close(self) -> None:
305305
async def __aenter__(self) -> DatabaseMemoryService:
306306
return self
307307

308-
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None:
308+
async def __aexit__(
309+
self,
310+
exc_type: Optional[type[BaseException]],
311+
exc_val: Optional[BaseException],
312+
exc_tb: Any,
313+
) -> None:
314+
"""Exits the async context manager and closes the service."""
309315
await self.close()
310316

311317
# -- keyword helpers ------------------------------------------------------

0 commit comments

Comments
 (0)