Skip to content

remove pydantic sqlmodel alembic dep#6293

Merged
masenf merged 4 commits intomainfrom
remove-pydantic-sqlmodel-alembic-dep
Apr 7, 2026
Merged

remove pydantic sqlmodel alembic dep#6293
masenf merged 4 commits intomainfrom
remove-pydantic-sqlmodel-alembic-dep

Conversation

@adhami3310
Copy link
Copy Markdown
Member

No description provided.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing remove-pydantic-sqlmodel-alembic-dep (0c9247e) with main (f6fab94)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR moves pydantic, sqlmodel, and alembic from reflex's required dependencies into a new optional [db] extra in pyproject.toml, and adds CI steps to verify that unit tests pass without these packages installed.

  • pyproject.toml: A new [project.optional-dependencies] db section is created containing alembic >=1.15.2,<2.0, pydantic >=2.12.0,<3.0, and sqlmodel >=0.0.24,<0.1. These remain available to developers via the [dependency-groups] dev group.
  • .github/workflows/unit_tests.yml: A new "Run unit tests without db dependencies" step is added to both the Linux/Windows matrix and the unit-tests-macos job. It forcibly removes pydantic alembic sqlalchemy sqlmodel via uv pip uninstall, runs pytest tests/units --no-sync, then restores the environment with uv sync.
  • Incomplete goal: packages/reflex-base/pyproject.toml still declares pydantic >=1.10.21,<3.0 as a hard required dependency. Since reflex-base is a non-optional dependency of reflex, pydantic will still be transitively installed for every reflex user — making the pydantic entry in the new [db] extra a version-constraint tightener rather than a true opt-in. Notably, reflex-base's own code already uses find_spec(\"pydantic\") guards throughout, indicating it's ready to have pydantic made truly optional at the metadata level too.

Confidence Score: 4/5

Mergeable for CI hardening purposes, but the stated goal of making pydantic optional for end-users is not fully achieved in this PR

A P1 finding exists: pydantic remains a required transitive dependency through reflex-base's pyproject.toml, meaning installing 'reflex' without '[db]' still installs pydantic. The code-level guards (find_spec checks) are in place in reflex-base, so the CI test is meaningful, but the package metadata is incomplete. Score is 4 because this should be addressed to fully realize the intent.

pyproject.toml (the db optional extra's pydantic entry is redundant until packages/reflex-base/pyproject.toml is also updated to make pydantic optional)

Important Files Changed

Filename Overview
pyproject.toml Moves pydantic, alembic, sqlmodel to optional [db] extra — but pydantic remains a required transitive dep through reflex-base, so the goal is only partially achieved
.github/workflows/unit_tests.yml Adds pre-test uninstall+test+resync step to both unit-test jobs to validate db-free operation; minor concern around uv pip uninstall exit codes
uv.lock Lockfile updated to reflect the new optional dependency grouping; no direct issues

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[uv sync - full env with all deps] --> B
    B["uv pip uninstall\npydantic alembic sqlalchemy sqlmodel"] --> C
    C["uv run --no-sync pytest tests/units"] -->|pass| D[uv sync - restore full env]
    C -->|fail| E[❌ CI Fails]
    D --> F[uv run pytest tests/units]
    F --> G["uv run pytest tests/units\nwith redis"]
    G --> H["uv run pytest tests/units\nwith redis + OPLOCK"]
    H --> I[uv run coverage html]
    style B fill:#ffe4b5
    style C fill:#ffe4b5
    style E fill:#f66,color:#fff
Loading

Comments Outside Diff (1)

  1. pyproject.toml, line 62-67 (link)

    P1 pydantic remains a required transitive dependency

    packages/reflex-base/pyproject.toml declares pydantic >=1.10.21,<3.0 as a hard required dependency, and reflex-base is listed as a required (non-optional) dependency of reflex. This means pip install reflex will still always install pydantic regardless of whether the [db] extra is specified.

    The pydantic >=2.12.0,<3.0 entry in the new [db] optional extra therefore only tightens the version constraint for db-using installs — it does not make pydantic itself optional for reflex end-users. To fully achieve the stated goal, packages/reflex-base/pyproject.toml would also need to make its pydantic dependency optional.

    Noting that reflex-base already guards its own pydantic usage at runtime with find_spec("pydantic") checks in serializers.py, base_state_processor.py, and vars/object.py — so the runtime code is already prepared. Only the package metadata needs to be updated.

Reviews (1): Last reviewed commit: "remove pydantic sqlmodel alembic dep" | Re-trigger Greptile

@masenf masenf merged commit 7140079 into main Apr 7, 2026
54 of 56 checks passed
@masenf masenf deleted the remove-pydantic-sqlmodel-alembic-dep branch April 7, 2026 16:44
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