Skip to content

Commit c7d6095

Browse files
committed
tomli is an optional dependency
1 parent 7829cb5 commit c7d6095

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
ITables ChangeLog
22
=================
33

4+
2.5.1 (2025-08-31)
5+
------------------
6+
7+
**Changed**
8+
- `tomli` is an optional dependency of ITables
9+
410
2.5.0 (2025-08-31)
511
------------------
612

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ classifiers = [
2727
"Typing :: Typed",
2828
]
2929
requires-python = ">= 3.9"
30-
dependencies = ["IPython", "pandas", "numpy", "tomli;python_version<\"3.11\""]
30+
dependencies = ["IPython", "pandas", "numpy"]
3131
dynamic = ["version"]
3232

3333
[project.optional-dependencies]
34+
config = ["tomli;python_version<\"3.11\""]
3435
polars = ["polars", "pyarrow"]
3536
check_type = ["typeguard>=4.4.1"]
3637
style = ["matplotlib"]
@@ -39,7 +40,7 @@ widget = ["anywidget", "traitlets"]
3940
streamlit = ["streamlit"]
4041
dash = ["dash"]
4142
shiny = ["shiny", "shinywidgets"]
42-
all = ["itables[polars,style,samples,widget,dash,shiny,streamlit,check_type]"]
43+
all = ["itables[config,polars,style,samples,widget,dash,shiny,streamlit,check_type]"]
4344
test = [
4445
"itables[all]",
4546
# Pytest

src/itables/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
try:
1717
import tomllib
1818
except ImportError:
19-
import tomli as tomllib # pyright: ignore[reportMissingImports]
19+
try:
20+
import tomli as tomllib # pyright: ignore[reportMissingImports]
21+
except ImportError:
22+
tomllib = None # type: ignore[assignment]
2023

2124
from platformdirs import user_config_path
2225

@@ -50,6 +53,8 @@ def get_config_file(path: Path = Path.cwd()) -> Optional[Path]:
5053
config_file = parent / "pyproject.toml"
5154
if config_file.exists():
5255
with open(config_file, "rb") as fp:
56+
if tomllib is None:
57+
continue
5358
config = tomllib.load(fp)
5459
if "tool" not in config or "itables" not in config["tool"]:
5560
continue
@@ -65,6 +70,9 @@ def get_config_file(path: Path = Path.cwd()) -> Optional[Path]:
6570

6671

6772
def load_config_file(config_file: Path) -> ITableOptions:
73+
if tomllib is None:
74+
raise ImportError(f"Either tomllib or tomli is required to load {config_file}")
75+
6876
with open(config_file, "rb") as fp:
6977
try:
7078
config = tomllib.load(fp)

src/itables/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""ITables' version number"""
22

3-
__version__ = "2.5.0"
3+
__version__ = "2.5.1"

0 commit comments

Comments
 (0)