fix: Python 3.6 compatibility for tests
- Replace walrus operator (:=) with traditional assignment in config.py - Replace datetime.fromisoformat() with strptime() for Python 3.6 - Replace subprocess capture_output and text params with PIPE and universal_newlines - All tests now pass on Python 3.6.9 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -46,16 +46,20 @@ class TddaiConfig:
|
||||
config = cls()
|
||||
|
||||
# Override with environment variables if present
|
||||
if gitea_url := os.getenv("TDDAI_GITEA_URL"):
|
||||
gitea_url = os.getenv("TDDAI_GITEA_URL")
|
||||
if gitea_url:
|
||||
config.gitea_url = gitea_url
|
||||
|
||||
if repo_owner := os.getenv("TDDAI_REPO_OWNER"):
|
||||
repo_owner = os.getenv("TDDAI_REPO_OWNER")
|
||||
if repo_owner:
|
||||
config.repo_owner = repo_owner
|
||||
|
||||
if repo_name := os.getenv("TDDAI_REPO_NAME"):
|
||||
repo_name = os.getenv("TDDAI_REPO_NAME")
|
||||
if repo_name:
|
||||
config.repo_name = repo_name
|
||||
|
||||
if workspace_dir := os.getenv("TDDAI_WORKSPACE_DIR"):
|
||||
workspace_dir = os.getenv("TDDAI_WORKSPACE_DIR")
|
||||
if workspace_dir:
|
||||
config.workspace_dir = Path(workspace_dir)
|
||||
|
||||
return config
|
||||
|
||||
@@ -4,6 +4,7 @@ Issue fetching from Gitea API.
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
from subprocess import PIPE
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import List, Optional, Dict, Any
|
||||
@@ -42,8 +43,9 @@ class IssueFetcher:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['curl', '-s', f"{self.config.issues_api_url}/{issue_number}"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
stdout=PIPE,
|
||||
stderr=PIPE,
|
||||
universal_newlines=True,
|
||||
check=True
|
||||
)
|
||||
|
||||
@@ -71,8 +73,9 @@ class IssueFetcher:
|
||||
|
||||
result = subprocess.run(
|
||||
['curl', '-s', url],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
stdout=PIPE,
|
||||
stderr=PIPE,
|
||||
universal_newlines=True,
|
||||
check=True
|
||||
)
|
||||
|
||||
@@ -111,8 +114,8 @@ class IssueFetcher:
|
||||
title=issue_data['title'],
|
||||
body=issue_data.get('body', ''),
|
||||
state=issue_data['state'],
|
||||
created_at=datetime.fromisoformat(issue_data['created_at'].replace('Z', '+00:00')),
|
||||
updated_at=datetime.fromisoformat(issue_data['updated_at'].replace('Z', '+00:00')),
|
||||
created_at=datetime.strptime(issue_data['created_at'].replace('Z', '').split('.')[0], '%Y-%m-%dT%H:%M:%S'),
|
||||
updated_at=datetime.strptime(issue_data['updated_at'].replace('Z', '').split('.')[0], '%Y-%m-%dT%H:%M:%S'),
|
||||
html_url=issue_data['html_url'],
|
||||
assignee=assignee,
|
||||
labels=labels
|
||||
|
||||
@@ -83,7 +83,7 @@ class WorkspaceManager:
|
||||
issue_title=issue_data['title'],
|
||||
issue_body=issue_data['body'],
|
||||
issue_state=issue_data['state'],
|
||||
created_at=datetime.fromisoformat(issue_data['created_at']),
|
||||
created_at=datetime.strptime(issue_data['created_at'].replace('Z', '').split('.')[0], '%Y-%m-%dT%H:%M:%S'),
|
||||
workspace_dir=self.config.workspace_dir
|
||||
)
|
||||
except (json.JSONDecodeError, KeyError, ValueError) as e:
|
||||
|
||||
Reference in New Issue
Block a user