Fix linting and type-checking issues

- Fix whitespace in docstring blank lines (ruff W293)
- Add null check before calling _validate_base_url to fix mypy type error
- Ensure url_to_validate is not None before validation

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-09-27 15:37:02 +00:00
parent 6c81e45ffd
commit d9d7ed00d1

View File

@@ -1200,7 +1200,7 @@ class LLM(BaseLLM):
# Validate base_url for Ollama connections
if "ollama" in self.model.lower() and (self.base_url or self.api_base):
url_to_validate = self.base_url or self.api_base
if not self._validate_base_url(url_to_validate):
if url_to_validate and not self._validate_base_url(url_to_validate):
raise ValueError(
f"Invalid Ollama base_url: '{url_to_validate}'. "
"Please check that the URL format is correct and the IP address is valid. "
@@ -1217,8 +1217,8 @@ class LLM(BaseLLM):
bool: True if URL is valid, False otherwise
"""
try:
from urllib.parse import urlparse
import ipaddress
from urllib.parse import urlparse
result = urlparse(url)