Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated-kwargs with removed-kwargs #6107

Merged
merged 1 commit into from Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/usage/errors.md
Expand Up @@ -381,7 +381,7 @@ except PydanticUserError as exc_info:
assert exc_info.code == 'config-both'
```

## Keyword arguments deprecated {#deprecated-kwargs}
## Keyword arguments removed {#removed-kwargs}

This error is raised when the keyword arguments are not available in Pydantic V2.

Expand All @@ -396,7 +396,7 @@ try:
x: str = Field(regex='test')

except PydanticUserError as exc_info:
assert exc_info.code == 'deprecated-kwargs'
assert exc_info.code == 'removed-kwargs'
```

## JSON schema invalid type {#invalid-for-json-schema}
Expand Down
2 changes: 1 addition & 1 deletion pydantic/errors.py
Expand Up @@ -32,7 +32,7 @@
'model-field-overridden',
'model-field-missing-annotation',
'config-both',
'deprecated-kwargs',
'removed-kwargs',
'invalid-for-json-schema',
'json-schema-already-used',
'base-model-instantiated',
Expand Down
6 changes: 3 additions & 3 deletions pydantic/fields.py
Expand Up @@ -665,7 +665,7 @@ def Field( # C901
# Check deprecated and removed params from V1. This logic should eventually be removed.
const = extra.pop('const', None) # type: ignore
if const is not None:
raise PydanticUserError('`const` is removed, use `Literal` instead', code='deprecated-kwargs')
raise PydanticUserError('`const` is removed, use `Literal` instead', code='removed-kwargs')

min_items = extra.pop('min_items', None) # type: ignore
if min_items is not None:
Expand All @@ -686,7 +686,7 @@ def Field( # C901
'`unique_items` is removed, use `Set` instead'
'(this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296)'
),
code='deprecated-kwargs',
code='removed-kwargs',
)

allow_mutation = extra.pop('allow_mutation', None) # type: ignore
Expand All @@ -697,7 +697,7 @@ def Field( # C901

regex = extra.pop('regex', None) # type: ignore
if regex is not None:
raise PydanticUserError('`regex` is removed. use `pattern` instead', code='deprecated-kwargs')
raise PydanticUserError('`regex` is removed. use `pattern` instead', code='removed-kwargs')

if extra:
warn(
Expand Down
2 changes: 1 addition & 1 deletion pydantic/types.py
Expand Up @@ -362,7 +362,7 @@ def conlist(
'`unique_items` is removed, use `Set` instead'
'(this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296)'
),
code='deprecated-kwargs',
code='removed-kwargs',
)
return Annotated[ # type: ignore[return-value]
List[item_type], # type: ignore[valid-type]
Expand Down