Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add private attributes support #1679
Add private attributes support #1679
Changes from 19 commits
5964240
d783caf
d4dabc4
c182678
1c7256a
ef640ff
3868ad3
d60de4c
9096f63
90576d2
a701b3e
33e3f28
dcfee02
063ba48
1333ffb
788d24b
dedb465
6ea1a1f
08d6f5d
60ebda2
2689d36
afa3fb9
47464ba
7fe179a
2090ba4
104d600
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I this needs documenting in
model_config.md
. Also we need to be clear exactly what form names need to be in.It looks from this like if you use
PrivateAttr
you can use_whatever
, but withunderscore_attrs_are_private
you have to use__whatever__
, but reading the code, I think that's not the case.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.
actually you've written it clear in the copy, but still better to use the same format in both code examples.
Is there anything special about
__whatever__
or is it just that it starts with an underscore, like_whatever
?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.
Since I think according to some PEP we're not supposed to use dunder methods, unless they're official to python, maybe leave them out of the example and just mention them in the text?
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.
why is this required?
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.
what do you mean exactly?
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.
Can we avoid this line since this is the critical path in terms of performance?
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.
It sets defaults of
__private_attributes__
, without this linedefault
notdefault_factoru
wouldn't work.What's critical here in terms of performance? Function call itself or executing code of the function?
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.
Ok, I guess we need it.
Initialising/validating models is the critical path, I don't want to slow that down unless we absolutely have to.
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.
had to set
# noqa: C901 (ignore complexity)
here because of today's changes in #1972. Is this the way to go, or something should be moved outside of this method?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.
i think this is fine.