Skip to content

Commit

Permalink
Added validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tk42 committed Sep 7, 2022
1 parent 7173413 commit 30d841d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="streamlit-excel-table",
version="0.2.2",
version="0.2.3",
author="tk42",
author_email="[email protected]",
description="Streamlit component implementation of react-awesome-table",
Expand Down
13 changes: 9 additions & 4 deletions st_excel_table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
# output value, and add a docstring for users.
def Table(
data: List[Dict],
columns: List[Dict] | None = None,
key: str | None = None,
columns: List[Dict] = None,
key: str = None,
sortable: bool = False,
filterable: bool = False,
**kwargs
**kwargs,
) -> None:
"""Create a new instance of "Table".
Expand All @@ -66,7 +66,12 @@ def Table(
"""

columns = [{"name": k} for k in data[0].keys()] if columns is None else columns
# All data must have the same keys.
header = data[0].keys()
for i, d in enumerate(data):
assert header == d.keys(), f"Index {i} {d.keys()} is not same with {header}"

columns = [{"name": k} for k in header] if columns is None else columns

options = {"sortable": False, "filterable": False}
if sortable:
Expand Down

0 comments on commit 30d841d

Please sign in to comment.