8000 Raise a deprecation warning when a field is annotated as final with a default value by Viicos · Pull Request #11168 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@Viicos
Copy link
Member
@Viicos Viicos commented Dec 21, 2024

Also adapt the collect_model_fields logic a bit.

Part of #11119.

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

@Viicos Viicos changed the title Raise a deprecation warning when a field is annotated as final with a… Raise a deprecation warning when a field is annotated as final with a default valut Dec 21, 2024
@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Dec 21, 2024
@cloudflare-workers-and-pages
Copy link
cloudflare-workers-and-pages bot commented Dec 21, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: d4fc9f1
Status: ✅  Deploy successful!
Preview URL: https://f378e618.pydantic-docs.pages.dev
Branch Preview URL: https://11119-1.pydantic-docs.pages.dev

View logs

@codspeed-hq
Copy link
codspeed-hq bot commented Dec 21, 2024

CodSpeed Performance Report

Merging #11168 will not alter performance

Comparing 11119-1 (d4fc9f1) with main (b236291)

Summary

✅ 46 untouched benchmarks

@github-actions
Copy link
Contributor
github-actions bot commented Dec 21, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  warnings.py
  pydantic/_internal
  _fields.py
Project Total  

This report was generated by python-coverage-comment-action

@Viicos Viicos changed the title Raise a deprecation warning when a field is annotated as final with a default valut Raise a deprecation warning when a field is annotated as final with a default value Dec 21, 2024
… default value

Also adapt the `collect_model_fields` logic a bit.
@Viicos Viicos added relnotes-change Used for changes to existing functionality which don't have a better categorization. and removed relnotes-fix Used for bugfixes. labels Dec 23, 2024
Copy link
Contributor
@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on the refactor using assigned_value instead of re-fetching depending on the branch you hit.

LGTM overall, I left a few minor change requests.

@pydantic-hooky pydantic-hooky bot added the awaiting author revision awaiting changes from the PR author label Dec 27, 2024
@sydney-runkle
Copy link
Contributor

Do we know why we treated finalvars with defaults as classvars in the past?

@Viicos
Copy link
Member Author
Viicos commented Dec 27, 2024

Do we know why we treated finalvars with defaults as classvars in the past?

As per the PR that implemented this:

Implementation is based on a PEP 591:

Type checkers should infer a final attribute that is initialized in a class body as being a class variable.

Copy link
Contributor
@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback looks good

@sydney-runkle sydney-runkle merged commit d823d8c into main Dec 27, 2024
58 checks passed
@sydney-runkle sydney-runkle deleted the 11119-1 branch December 27, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author revision awaiting changes from the PR author relnotes-change Used for changes to existing functionality which don't have a better categorization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0