Skip to content

make pydantic optional#6786

Open
benedikt-bartscher wants to merge 4 commits into
reflex-dev:mainfrom
benedikt-bartscher:make-pydantic-optional
Open

make pydantic optional#6786
benedikt-bartscher wants to merge 4 commits into
reflex-dev:mainfrom
benedikt-bartscher:make-pydantic-optional

Conversation

@benedikt-bartscher

Copy link
Copy Markdown
Contributor

No description provided.

@codspeed-hq

codspeed-hq Bot commented Jul 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:make-pydantic-optional (0e4656f) with main (2edaf12)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes pydantic an optional dependency for both reflex and reflex-base, replacing the hard requirement with a [pydantic] extra (and keeping it in [db] for database users). Pydantic model support now activates automatically when pydantic is present, requiring no code change from users who already install it via [db].

  • packages/reflex-base/pyproject.toml and pyproject.toml: pydantic moved from dependencies to [project.optional-dependencies]; new pydantic = ["reflex-base[pydantic]"] extra added at the root level.
  • tests/units/test_optional_pydantic.py: new subprocess test that installs a sys.meta_path filter to hide pydantic, purges sys.modules, then exercises state creation, component rendering, and serializers to confirm nothing crashes.
  • Breaking change news entries added for both packages.

Confidence Score: 5/5

Safe to merge; pydantic is cleanly demoted to an optional dep with a well-exercised test covering the no-pydantic path.

All changed files are straightforward: two pyproject.toml edits that move pydantic to an optional extra, a lock file update, and a new subprocess test verifying the no-pydantic path. The db extra still pulls pydantic for database users, so existing workflows are unaffected.

No files require special attention.

Important Files Changed

Filename Overview
packages/reflex-base/pyproject.toml Moves pydantic from a hard dependency to an optional extra [pydantic], matching the PR's intent.
pyproject.toml Adds pydantic = ["reflex-base[pydantic]"] optional extra; the db extra still includes pydantic directly, which is correct for database usage.
tests/units/test_optional_pydantic.py New subprocess-based test that blocks pydantic via a sys.meta_path filter and sys.modules purge, then verifies reflex imports, state, component render, and serializers all function correctly without pydantic.
uv.lock Lock file updated to reflect pydantic as an optional dep of reflex-base and a new pydantic extra for the root reflex package.
news/+pydantic-optional.breaking.md Breaking change notice informing users pydantic is no longer installed by default and pointing to reflex[pydantic] or reflex[db] extras.
packages/reflex-base/news/+pydantic-optional.breaking.md Breaking change notice for reflex-base package, mirroring the root-level news entry.

Reviews (4): Last reviewed commit: "greptile" | Re-trigger Greptile

Comment thread tests/units/test_optional_pydantic.py

@masenf masenf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

interesting; i thought we had pydantic as optional for some time now, but i guess not...

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review July 17, 2026 16:35
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner July 17, 2026 16:35
@benedikt-bartscher

Copy link
Copy Markdown
Contributor Author

interesting; i thought we had pydantic as optional for some time now, but i guess not...

I remember reading some git commits or changelogs which mentioned this as well - however somehow it currently isn't optional.

I guess this is ready for review now.

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.

2 participants