Skip to content

Commit 81dbf92

Browse files
Fix major mypy type checking issues
1 parent 9ad3728 commit 81dbf92

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

src/devo_global_comms_python/exceptions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,29 +423,29 @@ def create_exception_from_response(response: requests.Response) -> DevoAPIExcept
423423
request_id = None
424424

425425
# Extract rate limit headers
426-
retry_after = None
427-
limit = None
428-
remaining = None
426+
retry_after: Optional[int] = None
427+
limit: Optional[int] = None
428+
remaining: Optional[int] = None
429429

430430
if status_code == 429:
431-
retry_after = response.headers.get("Retry-After")
432-
if retry_after:
431+
retry_after_str = response.headers.get("Retry-After")
432+
if retry_after_str:
433433
try:
434-
retry_after = int(retry_after)
434+
retry_after = int(retry_after_str)
435435
except ValueError:
436436
retry_after = None
437437

438-
limit = response.headers.get("X-RateLimit-Limit")
439-
if limit:
438+
limit_str = response.headers.get("X-RateLimit-Limit")
439+
if limit_str:
440440
try:
441-
limit = int(limit)
441+
limit = int(limit_str)
442442
except ValueError:
443443
limit = None
444444

445-
remaining = response.headers.get("X-RateLimit-Remaining")
446-
if remaining:
445+
remaining_str = response.headers.get("X-RateLimit-Remaining")
446+
if remaining_str:
447447
try:
448-
remaining = int(remaining)
448+
remaining = int(remaining_str)
449449
except ValueError:
450450
remaining = None
451451

src/devo_global_comms_python/models/contact_groups.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class ContactsGroup(BaseModel):
99
Contact group model representing a collection of contacts.
1010
"""
1111

12-
id: str = Field(..., description="Unique identifier for the contact group")
13-
name: str = Field(..., description="Name of the contact group")
12+
id: str = Field(description="Unique identifier for the contact group")
13+
name: str = Field(description="Name of the contact group")
1414
description: Optional[str] = Field(None, description="Description of the contact group")
1515
contacts_count: Optional[int] = Field(None, description="Number of contacts in the group")
1616
created_at: Optional[datetime] = Field(None, description="Creation timestamp")
@@ -24,7 +24,7 @@ class CreateContactsGroupDto(BaseModel):
2424
DTO for creating a new contact group.
2525
"""
2626

27-
name: str = Field(..., description="Name of the contact group", min_length=1, max_length=255)
27+
name: str = Field(description="Name of the contact group", min_length=1, max_length=255)
2828
description: Optional[str] = Field(None, description="Description of the contact group", max_length=1000)
2929
contact_ids: Optional[List[str]] = Field(None, description="List of contact IDs to add to the group")
3030
metadata: Optional[Dict[str, Any]] = Field(None, description="Additional metadata")
@@ -46,7 +46,7 @@ class DeleteContactsGroupsDto(BaseModel):
4646
DTO for bulk deleting contact groups.
4747
"""
4848

49-
group_ids: List[str] = Field(..., description="List of contact group IDs to delete", min_items=1)
49+
group_ids: List[str] = Field(description="List of contact group IDs to delete", min_length=1)
5050
transfer_contacts_to: Optional[str] = Field(None, description="Group ID to transfer contacts to before deletion")
5151

5252

@@ -55,8 +55,8 @@ class ContactsGroupListResponse(BaseModel):
5555
Response model for listing contact groups with pagination.
5656
"""
5757

58-
groups: List[ContactsGroup] = Field(..., description="List of contact groups")
59-
total: int = Field(..., description="Total number of groups")
60-
page: int = Field(..., description="Current page number")
61-
limit: int = Field(..., description="Number of items per page")
62-
total_pages: int = Field(..., description="Total number of pages")
58+
groups: List[ContactsGroup] = Field(description="List of contact groups")
59+
total: int = Field(description="Total number of groups")
60+
page: int = Field(description="Current page number")
61+
limit: int = Field(description="Number of items per page")
62+
total_pages: int = Field(description="Total number of pages")

src/devo_global_comms_python/models/contacts.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Contact(BaseModel):
99
Contact model representing a contact in the Devo Global Communications API.
1010
"""
1111

12-
id: str = Field(..., description="Unique identifier for the contact")
12+
id: str = Field(description="Unique identifier for the contact")
1313
account_id: Optional[str] = Field(None, description="Account identifier")
1414
user_id: Optional[str] = Field(None, description="User identifier")
1515
phone_number: Optional[str] = Field(None, description="Contact phone number in E.164 format")
@@ -160,7 +160,7 @@ class DeleteContactsDto(BaseModel):
160160
Data transfer object for deleting contacts.
161161
"""
162162

163-
contact_ids: List[str] = Field(..., min_items=1, description="List of contact IDs to delete")
163+
contact_ids: List[str] = Field(description="List of contact IDs to delete", min_length=1)
164164

165165
@validator("contact_ids")
166166
def validate_contact_ids(cls, v):
@@ -175,8 +175,8 @@ class AssignToContactsGroupDto(BaseModel):
175175
Data transfer object for assigning/unassigning contacts to/from groups.
176176
"""
177177

178-
contact_ids: List[str] = Field(..., min_items=1, description="List of contact IDs")
179-
contacts_group_id: str = Field(..., description="Contact group ID")
178+
contact_ids: List[str] = Field(description="List of contact IDs", min_length=1)
179+
contacts_group_id: str = Field(description="Contact group ID")
180180

181181
@validator("contact_ids")
182182
def validate_contact_ids(cls, v):
@@ -198,7 +198,7 @@ class CreateContactsFromCsvDto(BaseModel):
198198
Data transfer object for importing contacts from CSV.
199199
"""
200200

201-
csv_data: str = Field(..., description="CSV data as string")
201+
csv_data: str = Field(description="CSV data as string")
202202
contacts_group_id: Optional[str] = Field(None, description="Contact group ID to assign imported contacts")
203203
skip_duplicates: Optional[bool] = Field(True, description="Skip duplicate contacts")
204204
update_existing: Optional[bool] = Field(False, description="Update existing contacts")
@@ -216,10 +216,10 @@ class CreateContactsFromCsvRespDto(BaseModel):
216216
Response data transfer object for CSV import operation.
217217
"""
218218

219-
total_processed: int = Field(..., description="Total number of contacts processed")
220-
successfully_created: int = Field(..., description="Number of contacts successfully created")
221-
skipped_duplicates: int = Field(..., description="Number of duplicate contacts skipped")
222-
failed_imports: int = Field(..., description="Number of failed imports")
219+
total_processed: int = Field(description="Total number of contacts processed")
220+
successfully_created: int = Field(description="Number of contacts successfully created")
221+
skipped_duplicates: int = Field(description="Number of duplicate contacts skipped")
222+
failed_imports: int = Field(description="Number of failed imports")
223223
errors: Optional[List[str]] = Field(None, description="List of error messages")
224224

225225

@@ -228,11 +228,11 @@ class GetContactsSerializer(BaseModel):
228228
Serializer for paginated contacts list response.
229229
"""
230230

231-
contacts: List[ContactSerializer] = Field(..., description="List of contacts")
232-
total: int = Field(..., description="Total number of contacts")
233-
page: int = Field(..., description="Current page number")
234-
limit: int = Field(..., description="Number of contacts per page")
235-
total_pages: int = Field(..., description="Total number of pages")
231+
contacts: List[ContactSerializer] = Field(description="List of contacts")
232+
total: int = Field(description="Total number of contacts")
233+
page: int = Field(description="Current page number")
234+
limit: int = Field(description="Number of contacts per page")
235+
total_pages: int = Field(description="Total number of pages")
236236

237237
@validator("page")
238238
def validate_page(cls, v):
@@ -255,9 +255,9 @@ class CustomField(BaseModel):
255255
Custom field model.
256256
"""
257257

258-
id: str = Field(..., description="Unique identifier for the custom field")
259-
name: str = Field(..., description="Custom field name")
260-
field_type: str = Field(..., description="Field type (text, number, date, boolean, etc.)")
258+
id: str = Field(description="Unique identifier for the custom field")
259+
name: str = Field(description="Custom field name")
260+
field_type: str = Field(description="Field type (text, number, date, boolean, etc.)")
261261
description: Optional[str] = Field(None, description="Custom field description")
262262
is_required: Optional[bool] = Field(False, description="Whether the field is required")
263263
default_value: Optional[Any] = Field(None, description="Default value for the field")
@@ -280,8 +280,8 @@ class CreateCustomFieldDto(BaseModel):
280280
Data transfer object for creating a custom field.
281281
"""
282282

283-
name: str = Field(..., description="Custom field name")
284-
field_type: str = Field(..., description="Field type (text, number, date, boolean, etc.)")
283+
name: str = Field(description="Custom field name")
284+
field_type: str = Field(description="Field type (text, number, date, boolean, etc.)")
285285
description: Optional[str] = Field(None, description="Custom field description")
286286
is_required: Optional[bool] = Field(False, description="Whether the field is required")
287287
default_value: Optional[Any] = Field(None, description="Default value for the field")
@@ -337,11 +337,11 @@ class GetCustomFieldsSerializer(BaseModel):
337337
Serializer for paginated custom fields list response.
338338
"""
339339

340-
custom_fields: List[CustomFieldSerializer] = Field(..., description="List of custom fields")
341-
total: int = Field(..., description="Total number of custom fields")
342-
page: int = Field(..., description="Current page number")
343-
limit: int = Field(..., description="Number of custom fields per page")
344-
total_pages: int = Field(..., description="Total number of pages")
340+
custom_fields: List[CustomFieldSerializer] = Field(description="List of custom fields")
341+
total: int = Field(description="Total number of custom fields")
342+
page: int = Field(description="Current page number")
343+
limit: int = Field(description="Number of custom fields per page")
344+
total_pages: int = Field(description="Total number of pages")
345345

346346
@validator("page")
347347
def validate_page(cls, v):
@@ -363,7 +363,7 @@ class CommonDeleteDto(BaseModel):
363363
Common data transfer object for delete operations.
364364
"""
365365

366-
ids: List[str] = Field(..., min_items=1, description="List of IDs to delete")
366+
ids: List[str] = Field(description="List of IDs to delete", min_length=1)
367367

368368
@validator("ids")
369369
def validate_ids(cls, v):

src/devo_global_comms_python/resources/contacts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, List, Optional
1+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
22

33
from ..utils import validate_required_string
44
from .base import BaseResource
@@ -70,7 +70,7 @@ def list(
7070
Returns:
7171
GetContactsSerializer: Paginated list of contacts
7272
"""
73-
params = {"page": page, "limit": limit}
73+
params: Dict[str, Any] = {"page": page, "limit": limit}
7474

7575
if contacts_group_ids:
7676
params["contacts_group_ids"] = contacts_group_ids
@@ -221,7 +221,7 @@ def list_custom_fields(
221221
Returns:
222222
GetCustomFieldsSerializer: Paginated list of custom fields
223223
"""
224-
params = {"page": page, "limit": limit}
224+
params: Dict[str, Any] = {"page": page, "limit": limit}
225225

226226
if id:
227227
params["id"] = id

0 commit comments

Comments
 (0)