Skip to content

Commit c6f4c1c

Browse files
committed
Update deprecations to be consistent with other PRs
1 parent 570be83 commit c6f4c1c

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

sqlmodel/main.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,17 +395,12 @@ def Field(
395395
current_schema_extra = schema_extra or {}
396396

397397
if regex:
398-
warnings.warn(
399-
REGEX_PARAM_DEPRECATION_MSG,
400-
DeprecationWarning,
401-
stacklevel=2,
402-
)
403-
if "pattern" in current_schema_extra:
404-
warnings.warn(
405-
"Pass `pattern` parameter directly to Field instead of passing it via `schema_extra`",
406-
DeprecationWarning,
407-
stacklevel=2,
408-
)
398+
warnings.warn(REGEX_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
399+
400+
for param_name in ("pattern",):
401+
if param_name in current_schema_extra:
402+
msg = f"Pass `{param_name}` parameter directly to Field instead of passing it via `schema_extra`"
403+
warnings.warn(msg, UserWarning, stacklevel=2)
409404

410405
# Extract possible alias settings from schema_extra so we can control precedence
411406
schema_validation_alias = current_schema_extra.pop("validation_alias", None)

0 commit comments

Comments
 (0)