Skip to content

Commit

Permalink
fix: TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
Browse files Browse the repository at this point in the history
Signed-off-by: Teo <[email protected]>
  • Loading branch information
teocns committed Dec 30, 2024
1 parent 371c086 commit 5e0a430
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_agent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest import TestCase
from uuid import uuid4
from typing import Optional

from agentops import track_agent
from agentops.descriptor import agentops_property
Expand Down Expand Up @@ -99,15 +100,16 @@ def _model_validate(self):
def test_track_agent_with_pydantic_model(self):
"""Test setting agentops_agent_name with actual Pydantic BaseModel"""
try:
from typing import Optional
from pydantic import BaseModel, Field, model_validator
except ImportError:
self.skipTest("Pydantic not installed, skipping Pydantic model test")

@track_agent()
class TestAgentModel(BaseModel):
role: str = Field(default="test_role")
agentops_agent_name: str | None = None
agentops_agent_id: str | None = None
agentops_agent_name: Optional[str] = None
agentops_agent_id: Optional[str] = None

@model_validator(mode="after")
def set_agent_name(self):
Expand Down

0 comments on commit 5e0a430

Please sign in to comment.