Merge pull request #2907 from markparonyan/mypy-agent-copilot-skills

fix(typing): resolve mypy errors in agent.gns3_copilot.skills
This commit is contained in:
Jeremy Grossmann 2026-09-29 12:35:51 +02:00 committed by GitHub
commit f23302f52a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 11 deletions

View File

@ -248,7 +248,7 @@ class SkillsLoader:
continue continue
# Use device_type from YAML content as the key # Use device_type from YAML content as the key
# Fallback to filename stem if device_type not present # Fallback to filename stem if device_type not present
skill_key = skill_data.get("device_type") if isinstance(skill_data, dict) else None skill_key = skill_data.get("device_type")
if not skill_key: if not skill_key:
skill_key = yaml_file.stem skill_key = yaml_file.stem
logger.warning(f"No device_type in {yaml_file}, using filename '{skill_key}' as key") logger.warning(f"No device_type in {yaml_file}, using filename '{skill_key}' as key")

View File

@ -37,8 +37,10 @@ from typing import Optional, Dict, Any
try: try:
import git import git
GIT_AVAILABLE = True
except ImportError: except ImportError:
git = None GIT_AVAILABLE = False
from gns3server.config import Config from gns3server.config import Config
from .loader import SkillsLoader from .loader import SkillsLoader
@ -66,7 +68,7 @@ class SkillsManager:
- Version tracking - Version tracking
""" """
def __init__(self, repo_url: str = None, branch: str = "main", auto_update: bool = False): def __init__(self, repo_url: Optional[str] = None, branch: str = "main", auto_update: bool = False):
""" """
Initialize the skills manager. Initialize the skills manager.
@ -90,7 +92,7 @@ class SkillsManager:
self._repo: Optional["git.Repo"] = None self._repo: Optional["git.Repo"] = None
self._prompt_count = 0 self._prompt_count = 0
if git is None: if not GIT_AVAILABLE:
logger.warning("GitPython is not installed. Skills management features will be limited.") logger.warning("GitPython is not installed. Skills management features will be limited.")
def initialize(self) -> bool: def initialize(self) -> bool:
@ -134,7 +136,7 @@ class SkillsManager:
- Up to date → nothing - Up to date → nothing
- Network error → use existing files, log warning - Network error → use existing files, log warning
""" """
if git is None or self._repo is None: if not GIT_AVAILABLE or self._repo is None:
return return
# Check for uncommitted changes # Check for uncommitted changes
@ -173,7 +175,7 @@ class SkillsManager:
Returns: Returns:
True if successful, False otherwise True if successful, False otherwise
""" """
if git is None: if not GIT_AVAILABLE:
logger.error("GitPython is not installed. Cannot clone repository.") logger.error("GitPython is not installed. Cannot clone repository.")
return False return False
@ -347,7 +349,7 @@ class SkillsManager:
Returns: Returns:
Commit hash as string, or empty string if not available Commit hash as string, or empty string if not available
""" """
if git is None or self._repo is None: if not GIT_AVAILABLE or self._repo is None:
try: try:
self._repo = git.Repo(self.local_path) self._repo = git.Repo(self.local_path)
except Exception: except Exception:
@ -409,7 +411,7 @@ class SkillsManager:
Returns: Returns:
True if successful, False otherwise True if successful, False otherwise
""" """
if git is None: if not GIT_AVAILABLE:
logger.error("GitPython is not installed. Cannot rollback.") logger.error("GitPython is not installed. Cannot rollback.")
return False return False
@ -436,7 +438,7 @@ class SkillsManager:
Returns: Returns:
List of commit information dictionaries List of commit information dictionaries
""" """
if git is None: if not GIT_AVAILABLE:
return [] return []
try: try:

View File

@ -297,8 +297,6 @@ module = [
"gns3server.agent", # 2 "gns3server.agent", # 2
"gns3server.agent.gns3_copilot.chat_sessions_repository", # 8 "gns3server.agent.gns3_copilot.chat_sessions_repository", # 8
"gns3server.agent.gns3_copilot.gns3_client.api_handlers", # 10 "gns3server.agent.gns3_copilot.gns3_client.api_handlers", # 10
"gns3server.agent.gns3_copilot.skills.loader", # 1
"gns3server.agent.gns3_copilot.skills.manager", # 4
"gns3server.agent.gns3_copilot.tools_v2.config_tools_nornir", # 6 "gns3server.agent.gns3_copilot.tools_v2.config_tools_nornir", # 6
"gns3server.agent.gns3_copilot.tools_v2.display_tools_nornir", # 6 "gns3server.agent.gns3_copilot.tools_v2.display_tools_nornir", # 6
"gns3server.agent.gns3_copilot.tools_v2.gns3_packet_filter", # 1 "gns3server.agent.gns3_copilot.tools_v2.gns3_packet_filter", # 1