Instead of checking for extension, check if file exists

This commit is contained in:
Alberto Simoes committed 2026-01-08 15:00:00 +00:00
1 parent 870aa2cc3a
commit 201db5afcb
1 file changed
+6 -2
+6 -2
View File
@@ -124,7 +124,9 @@ class SerenaAgentMode(ToolInclusionDefinition, ToStringMixin):
@classmethod
def load(cls, name_or_path: str | Path) -> Self:
if str(name_or_path).endswith(".yml"):
# Check if it's a file path that exists
path = Path(name_or_path)
if path.exists() and path.is_file():
return cls.from_yaml(name_or_path)
return cls.from_name(str(name_or_path))
@@ -225,7 +227,9 @@ class SerenaAgentContext(ToolInclusionDefinition, ToStringMixin):
@classmethod
def load(cls, name_or_path: str | Path) -> Self:
if str(name_or_path).endswith(".yml"):
# Check if it's a file path that exists
path = Path(name_or_path)
if path.exists() and path.is_file():
return cls.from_yaml(name_or_path)
return cls.from_name(str(name_or_path))