Skip to content

Commit e8e2a13

Browse files
asachs01claude
andcommitted
fix: Correct Dict type alias instantiation in attachments
- Replace Dict[str, Any]() instantiation with plain dict returns - Update test assertions from .id to ["id"] syntax - All 430 tests now pass Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 22a4939 commit e8e2a13

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

py_autotask/entities/attachments.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def upload_file(
105105
result = response.json()
106106

107107
self.logger.info(f"Successfully uploaded attachment: {file_path.name}")
108-
return Dict[str, Any](**result.get("item", result))
108+
return result.get("item", result)
109109

110110
except requests.exceptions.Timeout:
111111
raise AutotaskTimeoutError(f"Upload timed out for file: {file_path.name}")
@@ -172,7 +172,7 @@ def upload_from_data(
172172
result = response.json()
173173

174174
self.logger.info(f"Successfully uploaded attachment from data: {filename}")
175-
return Dict[str, Any](**result.get("item", result))
175+
return result.get("item", result)
176176

177177
except Exception as e:
178178
self.logger.error(f"Failed to upload data as {filename}: {e}")
@@ -237,7 +237,7 @@ def get_attachments_for_entity(
237237
}
238238

239239
response = self.query(query)
240-
return [Dict[str, Any](**item) for item in response.items]
240+
return [item for item in response.items]
241241

242242
def delete_attachment(self, attachment_id: int) -> bool:
243243
"""
@@ -262,7 +262,7 @@ def get_attachment_info(self, attachment_id: int) -> Optional[Dict[str, Any]]:
262262
Attachment metadata or None if not found
263263
"""
264264
data = self.get(attachment_id)
265-
return Dict[str, Any](**data) if data else None
265+
return data if data else None
266266

267267
def batch_upload(
268268
self,

tests/test_attachments.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_upload_file_success(
9191
title="Test File",
9292
)
9393

94-
assert isinstance(result, AttachmentData)
94+
assert isinstance(result, dict)
9595
mock_client.session.post.assert_called_once()
9696

9797
@patch("py_autotask.entities.attachments.Path")
@@ -136,7 +136,7 @@ def test_upload_file_too_large(self, attachments_entity):
136136
parent_type="Ticket", parent_id=67890, file_path=temp_file_path
137137
)
138138

139-
assert isinstance(result, AttachmentData)
139+
assert isinstance(result, dict)
140140
finally:
141141
# Clean up
142142
os.unlink(temp_file_path)
@@ -165,7 +165,7 @@ def test_upload_from_data_success(self, attachments_entity, mock_client):
165165
title="Test Data File",
166166
)
167167

168-
assert isinstance(result, AttachmentData)
168+
assert isinstance(result, dict)
169169
mock_client.session.post.assert_called_once()
170170

171171
def test_upload_from_data_too_large(self, attachments_entity):
@@ -187,7 +187,7 @@ def test_upload_from_data_too_large(self, attachments_entity):
187187
filename="large.txt",
188188
)
189189

190-
assert isinstance(result, AttachmentData)
190+
assert isinstance(result, dict)
191191

192192
def test_download_file_success(self, attachments_entity, mock_client):
193193
"""Test successful file download."""
@@ -228,7 +228,7 @@ def test_get_attachments_for_entity(
228228
result = attachments_entity.get_attachments_for_entity("Ticket", 67890)
229229

230230
assert len(result) == 1
231-
assert isinstance(result[0], AttachmentData)
231+
assert isinstance(result[0], dict)
232232
mock_client.query.assert_called_once()
233233

234234
def test_get_attachment_info(
@@ -239,8 +239,8 @@ def test_get_attachment_info(
239239

240240
result = attachments_entity.get_attachment_info(12345)
241241

242-
assert isinstance(result, AttachmentData)
243-
assert result.id == 12345
242+
assert isinstance(result, dict)
243+
assert result["id"] == 12345
244244
mock_client.get.assert_called_once()
245245

246246
def test_delete_attachment_success(self, attachments_entity, mock_client):

0 commit comments

Comments
 (0)