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
Error if an invalid field name is used with Field #6797
Conversation
Deploying with Cloudflare Pages
|
elif isinstance(value, FieldInfo) and not is_valid_field_name(var_name): | ||
suggested_name = var_name.lstrip('_') or 'my_field' # don't suggest '' for all-underscore name | ||
raise NameError( | ||
f'Fields must not use names with leading underscores;' |
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.
f'Fields must not use names with leading underscores;' | |
f'Field() must not use names with leading underscores;' |
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.
We say Private attributes
above, which I was trying to mirror here with the description of what it was, rather than the function used to create it. I actually think it's less confusing like this because people might not realize that calling Field()
signals to pydantic that that thing should be a field, which is what I want to emphasize.
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.
Agree, I've edited my suggestion
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.
Other than minor suggestions LGTM!
Closes #6745