Skip to content

Commit

Permalink
Merge pull request #4 from reflex-dev/main
Browse files Browse the repository at this point in the history
Update to latest main.
  • Loading branch information
nevdelap authored Aug 23, 2023
2 parents 2e3ef76 + 57855f5 commit 8ca4887
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ importlib-metadata = {version = "^6.7.0", python = ">=3.7, <3.8"}
alembic = "^1.11.1"
platformdirs = "^3.10.0"
distro = {version = "^1.8.0", platform = "linux"}
python-engineio = "!=4.6.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
Expand Down
4 changes: 2 additions & 2 deletions reflex/components/datadisplay/datatable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Table components."""

from typing import Any, List
from typing import Any, Dict, List, Union

from reflex.components.component import Component
from reflex.components.tags import Tag
Expand Down Expand Up @@ -38,7 +38,7 @@ class DataTable(Gridjs):
resizable: Var[bool]

# Enable pagination.
pagination: Var[bool]
pagination: Var[Union[bool, Dict]]

@classmethod
def create(cls, *children, **props):
Expand Down
9 changes: 3 additions & 6 deletions reflex/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ def get_engine(url: Optional[str] = None):
)
# Print the SQL queries if the log level is INFO or lower.
echo_db_query = os.environ.get("SQLALCHEMY_ECHO") == "True"
return sqlmodel.create_engine(
url,
echo=echo_db_query,
# Needed for the admin dash.
connect_args={"check_same_thread": False},
)
# Needed for the admin dash on sqlite.
connect_args = {"check_same_thread": False} if url.startswith("sqlite") else {}
return sqlmodel.create_engine(url, echo=echo_db_query, connect_args=connect_args)


class Model(Base, sqlmodel.SQLModel):
Expand Down
13 changes: 11 additions & 2 deletions reflex/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from reflex import constants
from reflex.base import Base
from reflex.utils import format, types
from reflex.utils import console, format, types

if TYPE_CHECKING:
from reflex.state import State
Expand Down Expand Up @@ -831,7 +831,16 @@ def setter(state: State, value: Any):
state: The state within which we add the setter function.
value: The value to set.
"""
setattr(state, self.name, value)
if self.type_ in [int, float]:
try:
value = self.type_(value)
setattr(state, self.name, value)
except ValueError:
console.warn(
f"{self.name}: Failed conversion of {value} to '{self.type_.__name__}'. Value not set.",
)
else:
setattr(state, self.name, value)

setter.__qualname__ = self.get_setter_name()

Expand Down

0 comments on commit 8ca4887

Please sign in to comment.