-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Reflect namedtuple default values during validation #7144
Conversation
Deploying with Cloudflare Pages
|
please review |
@@ -1130,7 +1130,9 @@ def _namedtuple_schema(self, namedtuple_cls: Any, origin: Any) -> core_schema.Co | |||
|
|||
arguments_schema = core_schema.arguments_schema( | |||
[ | |||
self._generate_parameter_schema(field_name, annotation) | |||
self._generate_parameter_schema( | |||
field_name, annotation, default=namedtuple_cls._field_defaults.get(field_name, Parameter.empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this looks like a private attribute access, this _field_defaults
attribute is explicitly present in the type stubs for NamedTuple
— I think it's intended for public access, just has an underscore to prevent name collisions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #7134
Selected Reviewer: @hramezani