Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.2k
Do not evaluate annotations for private fields#10962
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fe38cc5
to2861b87
Comparecloudflare-workers-and-pagesbot commentedNov 24, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Deploying pydantic-docs with |
Latest commit: | 213b274 |
Status: | ✅ Deploy successful! |
Preview URL: | https://e420a41e.pydantic-docs.pages.dev |
Branch Preview URL: | https://private-fields-eval.pydantic-docs.pages.dev |
codspeed-hqbot commentedNov 24, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
CodSpeed Performance ReportMerging#10962 willnot alter performanceComparing Summary
|
github-actionsbot commentedNov 24, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Coverage reportClick to see where and how coverage changed
This report was generated bypython-coverage-comment-action |
2d35039
to76460e2
Comparepotiuk commentedNov 24, 2024
Nice! |
76460e2
to8446583
CompareThe `get_cls_type_hints` function is now split up, by defining anew `get_model_type_hints` function that is lenient.`get_cls_type_hints` is made non-lenient because it is used fortyped dictionaries and named tuples, where we want to eagerlyraise the `NameError`s that can occur during evaluation.While this may introduce some code duplication, this gives moreflexibility in the future. For instance, we know from the namespacemanagement refactor that typed dicts behaves quite differently fromnormal classes when it comes to using the `__annotations__` attribute(collected from bases by cpython, automatically converted to `ForwardRef`instances, etc). So we might define another separate `get_typed_dict_type_hints`function in the future.
8446583
to213b274
CompareThere 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.
Looks good, thanks@Viicos.
We might be able to reuse some shared logic between these functions in a future refactor, but the fix here is pretty simple, so I think we should get this across the line now 👍
2a8078a
intomainUh oh!
There was an error while loading.Please reload this page.
The Pydantic 2.10.0/2.10.1 workaround implemented inapache#44317 is notneeded any more as it has been fixed in Pydantic 2.10.2 inthepydantic/pydantic#10962This PR removes the workaround and bumps min Pydantic version to2.10.2.
The Pydantic 2.10.0/2.10.1 workaround implemented in#44317 is notneeded any more as it has been fixed in Pydantic 2.10.2 inthepydantic/pydantic#10962This PR removes the workaround and bumps min Pydantic version to2.10.2.
The Pydantic 2.10.0/2.10.1 workaround implemented inapache#44317 is notneeded any more as it has been fixed in Pydantic 2.10.2 inthepydantic/pydantic#10962This PR removes the workaround and bumps min Pydantic version to2.10.2.
The Pydantic 2.10.0/2.10.1 workaround implemented inapache#44317 is notneeded any more as it has been fixed in Pydantic 2.10.2 inthepydantic/pydantic#10962This PR removes the workaround and bumps min Pydantic version to2.10.2.
The Pydantic 2.10.0/2.10.1 workaround implemented inapache#44317 is notneeded any more as it has been fixed in Pydantic 2.10.2 inthepydantic/pydantic#10962This PR removes the workaround and bumps min Pydantic version to2.10.2.
The Pydantic 2.10.0/2.10.1 workaround implemented in #44317 is notneeded any more as it has been fixed in Pydantic 2.10.2 inthepydantic/pydantic#10962This PR removes the workaround and bumps min Pydantic version to2.10.2.GitOrigin-RevId: b134ed089b74021858ded34dbc021ef053427650
Doing sofixes#10958 andgtalarico/pyairtable#411. We don't need to evaluate annotation for private fields because we will not make use of the type hint in any way.
The
get_cls_type_hints
function is now split up, by defining a newget_model_type_hints
function that is lenient.get_cls_type_hints
is made non-lenient because it is used for typed dictionaries and named tuples, where we want to eagerly raise theNameError
s that can occur during evaluation.While this may introduce some code duplication, this gives more flexibility in the future. For instance, we know from the namespace management refactor that typed dicts behaves quite differently from normal classes when it comes to using the
__annotations__
attribute (collected from bases by cpython, automatically converted toForwardRef
instances, etc). So we might define another separateget_typed_dict_type_hints
function in the future.Change Summary
Related issue number
Checklist