Skip to content

Commit

Permalink
fix: Add type ignore comments for Google Calendar tool classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-jrzz committed Nov 29, 2024
1 parent 62b997e commit a95891e
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"ConneryToolkit",
"FileManagementToolkit",
"GmailToolkit",
"GoogleCalendarToolkit",
"JiraToolkit",
"JsonToolkit",
"MultionToolkit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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": ["[email protected]", "[email protected]"]
"attendees": ["[email protected]", "[email protected]"],
}
result = tool.run(tool_input)
assert tool.args_schema is not None
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit a95891e

Please sign in to comment.