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 blogpost for pydantic v2 #2492

Merged
merged 9 commits into from
Dec 21, 2024
Merged

Conversation

joostlek
Copy link
Member

@joostlek joostlek commented Dec 10, 2024

Proposed change

Add blogpost for pydantic v2

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Removed stale or deprecated documentation

Additional information

Summary by CodeRabbit

  • New Features
    • Introduced an article on the transition from Pydantic v1 to Pydantic v2, detailing compatibility and migration guidance.

@bdraco
Copy link
Member

bdraco commented Dec 10, 2024

bdraco
bdraco previously approved these changes Dec 10, 2024
frenck
frenck previously approved these changes Dec 10, 2024

Pydantic is a widely used library in Python for data validation. On June 30, 2023, Pydantic v2 was released, introducing significant changes that are not backward compatible with Pydantic v1.

Home Assistant Core 2024.12 continues to ship with the Pydantic v1 library. Over the past year, our community has worked hard to ensure that the libraries used by Home Assistant Core are compatible with both Pydantic v1 and v2. This dual compatibility has helped make our transition to Pydantic v2 as smooth as possible.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Home Assistant Core 2024.12 continues to ship with the Pydantic v1 library. Over the past year, our community has worked hard to ensure that the libraries used by Home Assistant Core are compatible with both Pydantic v1 and v2. This dual compatibility has helped make our transition to Pydantic v2 as smooth as possible.
Over the past year, our community has worked hard to ensure that the libraries used by Home Assistant Core are compatible with both Pydantic v1 and v2. This dual compatibility has helped make our transition to Pydantic v2 as smooth as possible.

This reads a bit off, perhaps it's not necessary at ll?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still have a few subreleases until the end of the year, so I think it might help being explicit here that this only applies from 2025.1 onwards

author: Joost Lekkerkerker
authorURL: https://github.com/joostlek
authorImageURL: https://avatars.githubusercontent.com/u/7083755?v=4
title: "Pydantic bump to v2"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
title: "Pydantic bump to v2"
title: "Pydantic v2 mandatory from Home Assistant Core 2025.1"

Maybe something like this?

Copy link
Member Author

Choose a reason for hiding this comment

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

mandatory sounds like everything should use it, which is incorrect, it's only for pydantic v1-based intergation

Copy link
Member Author

Choose a reason for hiding this comment

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

But I do agree the current one is subpar, so open for other suggestions. We should both be trying to be a reason for action, but also make sure we target the right people

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, poor choice of words.. How about "Dropping support for pydantic v1 in 2025.1"?

Copy link
Member Author

Choose a reason for hiding this comment

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

"Moving from Pydantic v1 to v2"? (in 2025.1)?

Copy link
Member

@rytilahti rytilahti Dec 10, 2024

Choose a reason for hiding this comment

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

Sounds also good, I'd keep the version somehow in the title as it's a clear indication when the change happens. "End of pydantic v1 support in .." would also work.

Copy link
Contributor

Choose a reason for hiding this comment

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

"Moving to Pydantic v2"?


Home Assistant Core 2024.12 continues to ship with the Pydantic v1 library. Over the past year, our community has worked hard to ensure that the libraries used by Home Assistant Core are compatible with both Pydantic v1 and v2. This dual compatibility has helped make our transition to Pydantic v2 as smooth as possible.

Starting with Home Assistant Core 2025.1, Pydantic v2 will replace v1. If your custom integration uses Pydantic, it must be updated to support Pydantic v2 to keep working in the upcoming release.
Copy link
Contributor

@allenporter allenporter Dec 10, 2024

Choose a reason for hiding this comment

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

Swap the order of paragraph 2 and 3? This gets to the action needed sooner on what action needs to happen, then can get into details of how migration works

allenporter
allenporter previously approved these changes Dec 10, 2024
@joostlek joostlek marked this pull request as ready for review December 11, 2024 10:06
Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

📝 Walkthrough

Walkthrough

The pull request introduces a new blog post discussing the transition from Pydantic v1 to Pydantic v2 for Home Assistant Core. The article, authored by Joost Lekkerkerker, highlights the significant changes in Pydantic's versioning, focusing on the non-backward-compatible nature of Pydantic v2. It explains that Home Assistant Core version 2025.1 will standardize Pydantic v2, requiring updates to custom integrations and providing context about the community's efforts to facilitate a smooth migration.

Changes

File Change Summary
blog/2024-12-21-moving-to-pydantic-v2.md New blog post created discussing Pydantic v2 migration for Home Assistant Core

The changes consist of adding a single new blog post file that provides technical guidance and context for the upcoming Pydantic version transition in the Home Assistant ecosystem.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2aa1bd and 0edafd5.

📒 Files selected for processing (1)
  • blog/2024-12-21-moving-to-pydantic-v2.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • blog/2024-12-21-moving-to-pydantic-v2.md

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
blog/2024-12-10-moving-to-pydantic-v2.md (3)

5-5: Remove quotes from the title

Replace the quoted title with an unquoted one to follow the documentation guidelines.

-title: "Moving to Pydantic v2"
+title: Moving to Pydantic v2

10-10: Consider restructuring for emphasis on impact

While the content is correct, consider restructuring to emphasize the impact on custom integrations.

-Starting with Home Assistant Core 2025.1, Pydantic v2 will replace v1. If your custom integration uses Pydantic, it must be updated to support Pydantic v2 to keep working in the upcoming release.
+Custom integrations using Pydantic must be updated to support v2 to maintain functionality. Home Assistant Core 2025.1 will exclusively use Pydantic v2, replacing v1 completely.

14-14: Make the migration instruction more direct

Consider restructuring to provide a more direct instruction.

-For a quick migration, you can use the Pydantic v1 shims included in Pydantic v2. Detailed information about using these shims in a v1/v2 environment can be found in the [Pydantic migration guide](https://docs.pydantic.dev/latest/migration/#using-pydantic-v1-features-in-a-v1v2-environment).
+Use the Pydantic v1 shims included in Pydantic v2 for quick migration. Follow the [Pydantic migration guide](https://docs.pydantic.dev/latest/migration/#using-pydantic-v1-features-in-a-v1v2-environment) for detailed instructions on using these shims in a v1/v2 environment.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fc93ad4 and c5727c9.

📒 Files selected for processing (1)
  • blog/2024-12-10-moving-to-pydantic-v2.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
blog/2024-12-10-moving-to-pydantic-v2.md (6)

Pattern */**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.

  • Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
  • In step-by-step instructions, front the location phrase in the instructional sentence.
  • In step-by-step instructions, front the 'goal' in the instructional sentence.
  • In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
  • do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'

Pattern */**(html|markdown|md): - Use bold to mark UI strings.

  • If "" are used to mark UI strings, replace them by bold.

Pattern */**(html|markdown|md): - Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"


Pattern */**(html|markdown|md): - Use sentence-style capitalization also in headings.


Pattern */**(html|markdown|md): do not comment on HTML used for icons


Pattern */**(html|markdown|md): Avoid flagging inline HTML for embedding videos in future reviews for this repository.

🔇 Additional comments (2)
blog/2024-12-10-moving-to-pydantic-v2.md (2)

8-8: LGTM!

The introduction is clear, concise, and effectively communicates the context.


12-12: LGTM!

The context is well-explained and provides valuable information about the transition period.

@joostlek joostlek merged commit 2757650 into home-assistant:master Dec 21, 2024
5 checks passed
@joostlek joostlek deleted the pydantic-v2 branch December 21, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants