Skip to content

Conversation

tabassco
Copy link
Contributor

@tabassco tabassco commented Nov 3, 2023

Change Summary

See related issue for a minimal example.

  • When creating private fields from typing.Annotated, the default method gets thrown out in the current implementation.
  • This Pull-Requests adds functionality to check wether the Default in the Anntotated[] definition already is a PrivateAttr and uses it straight away.

Related issue number

fix #7955

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

Tim Kreitner added 2 commits November 3, 2023 12:03
Co-authored-by: Samuel Colvin <s@muelcolvin.com>

<!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->

## Change Summary
See related issue for a minimal example.

- When creating private fields from typing.Annotated, the default method gets thrown out in the current implementation.
- This Pull-Requests adds functionality to check wether the Default in the `Anntotated[]` definition already is a `PrivateAttr` and uses it straight away.

## Related issue number

fix pydantic#7955

## 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**
@sydney-runkle sydney-runkle added the relnotes-fix Used for bugfixes. label Nov 3, 2023
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.

Looks great, thanks for the contribution!

@sydney-runkle sydney-runkle merged commit b7d9281 into pydantic:main Nov 3, 2023
@tabassco tabassco deleted the 7955-fix-attr-error branch November 3, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-fix Used for bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use PrivateAttr with Annotated will cause AttributeError when getting private attr.
3 participants