Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Change the signature ofConfigWrapper.core_config to take the title directly#10562

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sydney-runkle merged 2 commits intomainfromcore-config-title
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Change the signature ofConfigWrapper.core_config to take the title…
… directly
  • Loading branch information
@Viicos
Viicos committedOct 7, 2024
commit1afd1ba9f0eed193193298013e0d445792b3108c
4 changes: 2 additions & 2 deletionspydantic/_internal/_config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ def __getattr__(self, name: str) -> Any:
except KeyError:
raise AttributeError(f'Config has no attribute {name!r}') from None

def core_config(self,obj: Any) -> core_schema.CoreConfig:
def core_config(self,title: str | None) -> core_schema.CoreConfig:
"""Create a pydantic-core config, `obj` is just used to populate `title` if not set in config.

Pass `obj=None` if you do not want to attempt to infer the `title`.
Expand DownExpand Up@@ -185,7 +185,7 @@ def core_config(self, obj: Any) -> core_schema.CoreConfig:
config['ser_json_timedelta'] = 'seconds_float'

core_config_values = {
'title': config.get('title') or(obj and obj.__name__),
'title': config.get('title') ortitle or None,
'extra_fields_behavior': config.get('extra'),
'allow_inf_nan': config.get('allow_inf_nan'),
'populate_by_name': config.get('populate_by_name'),
Expand Down
2 changes: 1 addition & 1 deletionpydantic/_internal/_dataclasses.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -175,7 +175,7 @@ def __init__(__dataclass_self__: PydanticDataclass, *args: Any, **kwargs: Any) -
set_dataclass_mocks(cls, cls.__name__, f'`{e.name}`')
return False

core_config = config_wrapper.core_config(cls)
core_config = config_wrapper.core_config(title=cls.__name__)

try:
schema = gen_schema.clean_schema(schema)
Expand Down
6 changes: 3 additions & 3 deletionspydantic/_internal/_generate_schema.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -675,7 +675,7 @@ def _model_schema(self, cls: type[BaseModel]) -> core_schema.CoreSchema:
{*fields.keys(), *computed_fields.keys()},
)
config_wrapper = ConfigWrapper(cls.model_config, check=False)
core_config = config_wrapper.core_config(cls)
core_config = config_wrapper.core_config(title=cls.__name__)
title = self._get_model_title_from_config(cls, config_wrapper)
metadata = build_metadata_dict(js_functions=[partial(modify_model_json_schema, cls=cls, title=title)])

Expand DownExpand Up@@ -1473,7 +1473,7 @@ def _typed_dict_schema(self, typed_dict_cls: Any, origin: Any) -> core_schema.Co
config = None

with self._config_wrapper_stack.push(config), self._types_namespace_stack.push(typed_dict_cls):
core_config = self._config_wrapper.core_config(typed_dict_cls)
core_config = self._config_wrapper.core_config(title=typed_dict_cls.__name__)

required_keys: frozenset[str] = typed_dict_cls.__required_keys__

Expand DownExpand Up@@ -1794,7 +1794,7 @@ def _dataclass_schema(
config = getattr(dataclass_base, '__pydantic_config__', None)
dataclass_bases_stack.enter_context(self._config_wrapper_stack.push(config))

core_config = self._config_wrapper.core_config(dataclass)
core_config = self._config_wrapper.core_config(title=dataclass.__name__)

from ..dataclasses import is_pydantic_dataclass

Expand Down
2 changes: 1 addition & 1 deletionpydantic/_internal/_model_construction.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -661,7 +661,7 @@ def complete_model_class(
set_model_mocks(cls, cls_name, f'`{e.name}`')
return False

core_config = config_wrapper.core_config(cls)
core_config = config_wrapper.core_config(title=cls.__name__)

try:
schema = gen_schema.clean_schema(schema)
Expand Down
2 changes: 1 addition & 1 deletionpydantic/_internal/_validate_call.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ def __init__(
config_wrapper = ConfigWrapper(config)
gen_schema = _generate_schema.GenerateSchema(config_wrapper, namespace)
schema = gen_schema.clean_schema(gen_schema.generate_schema(function))
core_config = config_wrapper.core_config(self)
core_config = config_wrapper.core_config(self.__name__)

self.__pydantic_validator__ = create_schema_validator(
schema,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp