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

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

Merged
sydney-runkle merged 1 commit intomainfromprivate-fields-eval
Nov 25, 2024

Conversation

Viicos
Copy link
Member

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.


Theget_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 theNameErrors 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

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedNov 24, 2024
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedNov 24, 2024
edited
Loading

CodSpeed Performance Report

Merging#10962 willnot alter performance

Comparingprivate-fields-eval (213b274) withmain (15f693a)

Summary

✅ 46 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedNov 24, 2024
edited
Loading

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic/_internal
  _fields.py
  _generate_schema.py
  _typing_extra.py506-507
Project Total 

This report was generated bypython-coverage-comment-action

@ViicosViicosforce-pushed theprivate-fields-eval branch 2 times, most recently from2d35039 to76460e2CompareNovember 24, 2024 17:56
@potiuk
Copy link

Nice!

The `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.
Copy link
Contributor

@sydney-runklesydney-runkle left a 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 👍

@sydney-runklesydney-runkle merged commit2a8078a intomainNov 25, 2024
54 checks passed
@sydney-runklesydney-runkle deleted the private-fields-eval branchNovember 25, 2024 15:19
potiuk added a commit to potiuk/airflow that referenced this pull requestNov 26, 2024
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.
ferruzzi pushed a commit to apache/airflow that referenced this pull requestNov 26, 2024
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.
ArshiaZr pushed a commit to ArshiaZr/airflow that referenced this pull requestNov 27, 2024
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.
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull requestJan 5, 2025
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.
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull requestJan 30, 2025
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.
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull requestMay 27, 2025
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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@potiukpotiukpotiuk approved these changes

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees
No one assigned
Labels
relnotes-fixUsed for bugfixes.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Missingeval-type-backport as required dependency in 2.10.* Pydantic line for Python 3.8/3.9
3 participants
@Viicos@potiuk@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp