[REF-3157] Avoid SQLModel metaclass conflict (#3610)

Ensure that reflex.utils.compat is loaded whenever `reflex` itself is imported
to try and avoid the sqlmodel metaclass conflict error that arises when
sqlmodel is imported first with pydantic v2, but reflex Model inherits from
rx.Base which is based on pydantic v1.

Fix #3515
This commit is contained in:
Masen Furer 2024-07-03 06:58:21 -07:00 committed by GitHub
parent 75c5fa2ffe
commit 7cbd2848ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -84,12 +84,18 @@ In the example above, you will be able to do `rx.list`
from __future__ import annotations
from reflex.utils import lazy_loader
from reflex.utils import (
compat, # for side-effects
lazy_loader,
)
# import this here explicitly to avoid returning the page module since page attr has the
# same name as page module(page.py)
from .page import page as page
# Remove the `compat` name from the namespace, it was imported for side-effects only.
del compat
RADIX_THEMES_MAPPING: dict = {
"components.radix.themes.base": ["color_mode", "theme", "theme_panel"],
"components.radix.themes.color_mode": ["color_mode"],

View File

@ -3,6 +3,8 @@
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
from reflex.utils import compat
from . import admin as admin
from . import app as app
from . import base as base
@ -190,6 +192,7 @@ from .utils.serializers import serializer as serializer
from .vars import Var as Var
from .vars import cached_var as cached_var
del compat
RADIX_THEMES_MAPPING: dict
RADIX_THEMES_COMPONENTS_MAPPING: dict
RADIX_THEMES_LAYOUT_MAPPING: dict