Skip to content

Commit 07ed3cc

Browse files
committed
Use 'schema' field and handle pydantic's warning
1 parent b41d8c5 commit 07ed3cc

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
import warnings
12
from typing import Literal
23

3-
from pydantic import ConfigDict, Field
4-
54
from workos.types.audit_logs.audit_log_schema import AuditLogSchema
65
from workos.types.workos_model import WorkOSModel
76

7+
# Suppress Pydantic warning about 'schema' shadowing BaseModel.schema()
8+
# (a deprecated method replaced by model_json_schema() in Pydantic v2)
9+
warnings.filterwarnings(
10+
"ignore",
11+
message='Field name "schema" in "AuditLogAction" shadows an attribute',
12+
category=UserWarning,
13+
)
14+
815

916
class AuditLogAction(WorkOSModel):
1017
"""Representation of a WorkOS audit log action.
@@ -14,10 +21,8 @@ class AuditLogAction(WorkOSModel):
1421
defines the structure of events for that action.
1522
"""
1623

17-
model_config = ConfigDict(populate_by_name=True)
18-
1924
object: Literal["audit_log_action"]
2025
name: str
21-
action_schema: AuditLogSchema = Field(alias="schema")
26+
schema: AuditLogSchema # type: ignore[assignment]
2227
created_at: str
2328
updated_at: str

tests/test_audit_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def test_succeeds(self, capture_and_mock_http_client_request):
538538
assert request_kwargs["method"] == "get"
539539
assert len(response.data) == 1
540540
assert response.data[0].name == "user.viewed_invoice"
541-
assert response.data[0].action_schema.version == 1
541+
assert response.data[0].schema.version == 1
542542

543543
def test_with_pagination_params(self, capture_and_mock_http_client_request):
544544
expected_payload = {

0 commit comments

Comments
 (0)