1
1
# --------------------------------------------------------------------
2
2
# Extends OIDC client auth model with an optional `token` field.
3
- # Works on Pydantic v1 and v2 .
3
+ # Works on Pydantic v2-only .
4
4
#
5
5
# Accepted credential sets (exactly **one** of):
6
6
# 1 pre-issued `token`
11
11
12
12
from typing import Literal , Optional
13
13
14
- from feast .repo_config import FeastConfigBaseModel
15
-
16
- # pick the correct validator decorator for current Pydantic version
17
- try : # Pydantic ≥ 2.0
18
- from pydantic import model_validator as _v2 # type: ignore
14
+ from pydantic import model_validator
19
15
20
- def _cred_validator (fn ):
21
- return _v2 (mode = "after" )(fn ) # run after field validation
22
- except ImportError : # Pydantic 1.x
23
- from pydantic import root_validator as _v1 # type: ignore
24
-
25
- def _cred_validator (fn ):
26
- return _v1 (skip_on_failure = True )(fn )
16
+ from feast .repo_config import FeastConfigBaseModel
27
17
28
18
29
19
class AuthConfig (FeastConfigBaseModel ):
@@ -42,7 +32,7 @@ class OidcClientAuthConfig(OidcAuthConfig):
42
32
client_secret : Optional [str ] = None
43
33
token : Optional [str ] = None # pre-issued `token`
44
34
45
- @_cred_validator
35
+ @model_validator ( mode = "after" )
46
36
def _validate_credentials (cls , values ):
47
37
"""Enforce exactly one valid credential set."""
48
38
d = values .__dict__ if hasattr (values , "__dict__" ) else values
0 commit comments