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

Update to latest main. #4

Merged
merged 4 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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