Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
ITables ChangeLog
=================

2.5.2-dev (2025-09-02)
------------------

**Fixed**
- `platformdirs` is an optional dependency of ITables ([#437](https://github.com/mwouts/itables/issues/437))


2.5.1 (2025-08-31)
------------------

Expand Down
4 changes: 3 additions & 1 deletion docs/options/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ itables.options.maxBytes = "128KB"

## Configuration File

Since v2.5.0, ITable can load its default options from a configuration file. The configuration file is identified using `get_config_file` from [`itables.config`](https://github.com/mwouts/itables/blob/main/src/itables/config.py). It can be:
Since v2.5.0, ITable can load its default options from a configuration file. This requires two dependencies: either `tomllib` or `tomli`, and `platformdirs`, which can be installed with `pip install itables[config]`.

The configuration file is identified using `get_config_file` from [`itables.config`](https://github.com/mwouts/itables/blob/main/src/itables/config.py). It can be:

- The file pointed to by the environment variable `ITABLES_CONFIG`, if set and non-empty (if the variable is an empty string, no configuration file is used)
- An `itables.toml` file in the current or a parent directory
Expand Down
4 changes: 3 additions & 1 deletion docs/py/options/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
#
# ## Configuration File
#
# Since v2.5.0, ITable can load its default options from a configuration file. The configuration file is identified using `get_config_file` from [`itables.config`](https://github.com/mwouts/itables/blob/main/src/itables/config.py). It can be:
# Since v2.5.0, ITable can load its default options from a configuration file. This requires two dependencies: either `tomllib` or `tomli`, and `platformdirs`, which can be installed with `pip install itables[config]`.
#
# The configuration file is identified using `get_config_file` from [`itables.config`](https://github.com/mwouts/itables/blob/main/src/itables/config.py). It can be:
#
# - The file pointed to by the environment variable `ITABLES_CONFIG`, if set and non-empty (if the variable is an empty string, no configuration file is used)
# - An `itables.toml` file in the current or a parent directory
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies = ["IPython", "pandas", "numpy"]
dynamic = ["version"]

[project.optional-dependencies]
config = ["tomli;python_version<\"3.11\""]
config = ["tomli;python_version<\"3.11\"", "platformdirs"]
polars = ["polars", "pyarrow"]
check_type = ["typeguard>=4.4.1"]
style = ["matplotlib"]
Expand Down
12 changes: 8 additions & 4 deletions src/itables/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
except ImportError:
tomllib = None # type: ignore[assignment]

from platformdirs import user_config_path
try:
from platformdirs import user_config_path
except ImportError:
user_config_path = None

from itables.typing import ITableOptions, check_itable_arguments

Expand Down Expand Up @@ -62,9 +65,10 @@ def get_config_file(path: Path = Path.cwd()) -> Optional[Path]:
if parent in ceiling_directories:
break

config_file = user_config_path("itables") / "itables.toml"
if config_file.exists():
return config_file
if user_config_path is not None:
config_file = user_config_path("itables") / "itables.toml"
if config_file.exists():
return config_file

return None

Expand Down
8 changes: 7 additions & 1 deletion src/itables/show_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@

from pathlib import Path

from itables.config import get_config_file, load_config_file
from itables.config import get_config_file, load_config_file, tomllib, user_config_path


def show_config(path: Path):
"""
Show the ITables config file location and content.
"""
if (tomllib is None) or (user_config_path is None):
print(
"Missing itables[config] dependencies. Please install them with 'pip install itables[config]"
)
return

if (config_file := get_config_file(path)) is None:
print("No ITables config file found")
return
Expand Down
2 changes: 1 addition & 1 deletion src/itables/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""ITables' version number"""

__version__ = "2.5.1"
__version__ = "2.5.2-dev"
Loading