From a95891eee822c9aef25821a402450f3703667a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20=C3=81ngel=20Ju=C3=A1rez=20V=C3=A1zquez?= Date: Fri, 29 Nov 2024 00:32:59 -0600 Subject: [PATCH] fix: Add type ignore comments for Google Calendar tool classes --- .../tools/google_calendar/base.py | 2 +- .../tools/google_calendar/create_event.py | 2 +- .../tools/google_calendar/delete_event.py | 2 +- .../google_calendar/get_calendars_info.py | 2 +- .../tools/google_calendar/move_event.py | 2 +- .../tools/google_calendar/search_events.py | 4 ++-- .../tools/google_calendar/update_event.py | 2 +- .../unit_tests/agent_toolkits/test_imports.py | 1 + .../google_calendar/test_create_event.py | 19 ++++++++++--------- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/libs/community/langchain_community/tools/google_calendar/base.py b/libs/community/langchain_community/tools/google_calendar/base.py index 6ebdb4d2fe0c2..e415ff33f7145 100644 --- a/libs/community/langchain_community/tools/google_calendar/base.py +++ b/libs/community/langchain_community/tools/google_calendar/base.py @@ -20,7 +20,7 @@ pass -class GoogleCalendarBaseTool(BaseTool): +class GoogleCalendarBaseTool(BaseTool): # type: ignore[override] """Base class for Google Calendar tools.""" api_resource: Resource = Field(default_factory=build_resource_service) diff --git a/libs/community/langchain_community/tools/google_calendar/create_event.py b/libs/community/langchain_community/tools/google_calendar/create_event.py index fd613d5fdab39..b849624b321bb 100644 --- a/libs/community/langchain_community/tools/google_calendar/create_event.py +++ b/libs/community/langchain_community/tools/google_calendar/create_event.py @@ -91,7 +91,7 @@ class CreateEventSchema(BaseModel): ) -class CalendarCreateEvent(GoogleCalendarBaseTool): +class CalendarCreateEvent(GoogleCalendarBaseTool): # type: ignore[override, override] """Tool that creates an event in Google Calendar.""" name: str = "create_calendar_event" diff --git a/libs/community/langchain_community/tools/google_calendar/delete_event.py b/libs/community/langchain_community/tools/google_calendar/delete_event.py index e299e6b8cacc2..6090415f88984 100644 --- a/libs/community/langchain_community/tools/google_calendar/delete_event.py +++ b/libs/community/langchain_community/tools/google_calendar/delete_event.py @@ -24,7 +24,7 @@ class DeleteEventSchema(BaseModel): ) -class CalendarDeleteEvent(GoogleCalendarBaseTool): +class CalendarDeleteEvent(GoogleCalendarBaseTool): # type: ignore[override, override] """Tool that delete an event in Google Calendar.""" name: str = "delete_calendar_event" diff --git a/libs/community/langchain_community/tools/google_calendar/get_calendars_info.py b/libs/community/langchain_community/tools/google_calendar/get_calendars_info.py index f2da16cbf8f23..c4b91160190c6 100644 --- a/libs/community/langchain_community/tools/google_calendar/get_calendars_info.py +++ b/libs/community/langchain_community/tools/google_calendar/get_calendars_info.py @@ -7,7 +7,7 @@ from langchain_community.tools.google_calendar.base import GoogleCalendarBaseTool -class GetCalendarsInfo(GoogleCalendarBaseTool): +class GetCalendarsInfo(GoogleCalendarBaseTool): # type: ignore[override, override] """Tool that get information about the calendars in Google Calendar.""" name: str = "get_calendars_info" diff --git a/libs/community/langchain_community/tools/google_calendar/move_event.py b/libs/community/langchain_community/tools/google_calendar/move_event.py index b954f20447a8d..b6445eba3b56c 100644 --- a/libs/community/langchain_community/tools/google_calendar/move_event.py +++ b/libs/community/langchain_community/tools/google_calendar/move_event.py @@ -25,7 +25,7 @@ class MoveEventSchema(BaseModel): ) -class CalendarMoveEvent(GoogleCalendarBaseTool): +class CalendarMoveEvent(GoogleCalendarBaseTool): # type: ignore[override, override] """Tool that move an event between calendars in Google Calendar.""" name: str = "move_calendar_event" diff --git a/libs/community/langchain_community/tools/google_calendar/search_events.py b/libs/community/langchain_community/tools/google_calendar/search_events.py index 6e255d4e7535f..20c8be53e46c8 100644 --- a/libs/community/langchain_community/tools/google_calendar/search_events.py +++ b/libs/community/langchain_community/tools/google_calendar/search_events.py @@ -2,10 +2,10 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Type -from zoneinfo import ZoneInfo # Python 3.9+ from langchain_core.callbacks import CallbackManagerForToolRun from pydantic import BaseModel, Field +from zoneinfo import ZoneInfo # Python 3.9+ from langchain_community.tools.google_calendar.base import GoogleCalendarBaseTool @@ -49,7 +49,7 @@ class SearchEventsSchema(BaseModel): ) -class CalendarSearchEvents(GoogleCalendarBaseTool): +class CalendarSearchEvents(GoogleCalendarBaseTool): # type: ignore[override, override] """Tool that retrieves events from Google Calendar.""" name: str = "search_events" diff --git a/libs/community/langchain_community/tools/google_calendar/update_event.py b/libs/community/langchain_community/tools/google_calendar/update_event.py index ded6a2f660e15..0ef836a3d4575 100644 --- a/libs/community/langchain_community/tools/google_calendar/update_event.py +++ b/libs/community/langchain_community/tools/google_calendar/update_event.py @@ -93,7 +93,7 @@ class UpdateEventSchema(BaseModel): ) -class CalendarUpdateEvent(GoogleCalendarBaseTool): +class CalendarUpdateEvent(GoogleCalendarBaseTool): # type: ignore[override, override] """Tool that updates an event in Google Calendar.""" name: str = "update_calendar_event" diff --git a/libs/community/tests/unit_tests/agent_toolkits/test_imports.py b/libs/community/tests/unit_tests/agent_toolkits/test_imports.py index 6002b42a950ff..4e8f6ebac46a8 100644 --- a/libs/community/tests/unit_tests/agent_toolkits/test_imports.py +++ b/libs/community/tests/unit_tests/agent_toolkits/test_imports.py @@ -8,6 +8,7 @@ "ConneryToolkit", "FileManagementToolkit", "GmailToolkit", + "GoogleCalendarToolkit", "JiraToolkit", "JsonToolkit", "MultionToolkit", diff --git a/libs/community/tests/unit_tests/tools/google_calendar/test_create_event.py b/libs/community/tests/unit_tests/tools/google_calendar/test_create_event.py index 7d629d7e07ce5..5aec4c08a4e3b 100644 --- a/libs/community/tests/unit_tests/tools/google_calendar/test_create_event.py +++ b/libs/community/tests/unit_tests/tools/google_calendar/test_create_event.py @@ -11,7 +11,7 @@ def test_create_simple_event() -> None: tool_input = { "summary": "Event summary", "start_datetime": "2025-07-11 14:00:00", - "end_datetime": "2025-07-11 15:30:00" + "end_datetime": "2025-07-11 15:30:00", } result = tool.run(tool_input) assert tool.args_schema is not None @@ -27,7 +27,7 @@ def test_create_event_with_description_and_location() -> None: "start_datetime": "2025-07-11 14:00:00", "end_datetime": "2025-07-11 15:30:00", "description": "Event description", - "location": "Sante Fe, Mexico City" + "location": "Sante Fe, Mexico City", } result = tool.run(tool_input) assert tool.args_schema is not None @@ -42,7 +42,7 @@ def test_create_event_with_attendees() -> None: "summary": "Event summary", "start_datetime": "2025-07-11 14:00:00", "end_datetime": "2025-07-11 15:30:00", - "attendees": ["fake123@email.com", "123fake@email.com"] + "attendees": ["fake123@email.com", "123fake@email.com"], } result = tool.run(tool_input) assert tool.args_schema is not None @@ -59,8 +59,8 @@ def test_create_event_with_reminders() -> None: "end_datetime": "2025-07-11 15:30:00", "reminders": [ {"method": "email", "minutes": 10}, - {"method": "popup", "minutes": 30} - ] + {"method": "popup", "minutes": 30}, + ], } result = tool.run(tool_input) assert tool.args_schema is not None @@ -76,14 +76,15 @@ def test_create_event_with_recurrence() -> None: "start_datetime": "2025-07-11 14:00:00", "end_datetime": "2025-07-11 15:30:00", "recurrence": { - 'FREQ': 'WEEKLY', - 'COUNT': 10 - } + "FREQ": "WEEKLY", + "COUNT": 10, + }, } result = tool.run(tool_input) assert tool.args_schema is not None assert result.startswith("Event created:") + def test_create_event_with_conference_data() -> None: """Test google calendar create event with conference data.""" mock_api_resource = MagicMock() @@ -92,7 +93,7 @@ def test_create_event_with_conference_data() -> None: "summary": "Event summary", "start_datetime": "2025-07-11 14:00:00", "end_datetime": "2025-07-11 15:30:00", - "conference_data": True + "conference_data": True, } result = tool.run(tool_input) assert tool.args_schema is not None