Skip to content

Commit 4609a0d

Browse files
committed
fix: update model_validator to use instance method signature
Pydantic v2.12 deprecated using @model_validator(mode='after') with a classmethod-style signature (cls, values). This change updates the _validate_credentials method to use the correct instance method signature (self), which: - Eliminates the deprecation warning - Uses direct attribute access (self.username) instead of dict access - Returns self instead of values This is a non-breaking change that maintains the same validation logic while conforming to Pydantic v2.12+ best practices. Fixes deprecation warning: 'Using @model_validator with mode="after" on a classmethod is deprecated'
1 parent b8d7562 commit 4609a0d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

sdk/python/feast/permissions/auth_model.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,23 @@ class OidcClientAuthConfig(OidcAuthConfig):
3333
token: Optional[str] = None # pre-issued `token`
3434

3535
@model_validator(mode="after")
36-
def _validate_credentials(cls, values):
36+
def _validate_credentials(self):
3737
"""Enforce exactly one valid credential set."""
38-
d = values.__dict__ if hasattr(values, "__dict__") else values
39-
40-
has_user_pass = bool(d.get("username")) and bool(d.get("password"))
41-
has_secret = bool(d.get("client_secret"))
42-
has_token = bool(d.get("token"))
38+
has_user_pass = bool(self.username) and bool(self.password)
39+
has_secret = bool(self.client_secret)
40+
has_token = bool(self.token)
4341

4442
# 1 static token
4543
if has_token and not (has_user_pass or has_secret):
46-
return values
44+
return self
4745

4846
# 2 client_credentials
4947
if has_secret and not has_user_pass and not has_token:
50-
return values
48+
return self
5149

5250
# 3 ROPG
5351
if has_user_pass and has_secret and not has_token:
54-
return values
52+
return self
5553

5654
raise ValueError(
5755
"Invalid OIDC client auth combination: "

0 commit comments

Comments
 (0)