Skip to content
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 a with_config decorator to comply with typing spec #8611

Merged
merged 4 commits into from Jan 26, 2024

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented Jan 23, 2024

May fix #8514, as suggested in a comment.

If accepted, better documentation will follow

Selected Reviewer: @dmontagu

Copy link

codspeed-hq bot commented Jan 23, 2024

CodSpeed Performance Report

Merging #8611 will not alter performance

Comparing Viicos:with-config-decorator (7daacab) with main (2792775)

Summary

✅ 10 untouched benchmarks

Copy link
Member

@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.

Hey @Viicos,

@dmontagu and I really like this approach. A few notes:

It'd be great if this could also be used with dataclasses. I think as it stands, it can, but you just haven't documented it yet. A few requests for changes (I know you wanted to get this approved before working on additional docs):

  1. Docs update with a vanilla example for both dataclass and TypedDict. Docs in both the "Concepts" section and "API Documentation" section (via docstrings) would be fantastic.
  2. mypy tests with this new decorator, as a proof of concept for how this fixes the original issue.

Thanks a bunch for your work on this - it'll be a great feature to have :).

@Viicos
Copy link
Contributor Author

Viicos commented Jan 24, 2024

Please review

Copy link
Member

@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.

@Viicos,

Changes look great. I've requested two small docs updates. Additionally, looks like the mypy test isn't working properly. Could you please update that when you have a chance?

Other than that, looks good to go! Thanks!

pydantic/config.py Outdated Show resolved Hide resolved
docs/concepts/config.md Show resolved Hide resolved
@sydney-runkle
Copy link
Member

@Viicos,

I've moved the attached issue into the 2.7.0 milestone :).

@sydney-runkle
Copy link
Member

@Viicos,

Amazing work 🚀. Merging this now to be included in 2.7.0!

@sydney-runkle sydney-runkle merged commit 3810c7b into pydantic:main Jan 26, 2024
54 checks passed
@Viicos Viicos deleted the with-config-decorator branch January 26, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

__pydantic_config__ fails with mypy
3 participants