Repository: tmux-python/tmuxp (language: python)

Issue:
Move `config_reader` to `_internal`
`config_reader` is a generic utility / helper.


Discussion / hints:

Fix patch:
diff --git a/CHANGES b/CHANGES
index 74d7187c6f..df1dbc7baf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,7 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
 - libtmux: 0.24.1 -> 0.25.0, maintenance release (#896)
 
   Improve styling via pydocstyle.
+- `config_reader`: Move to `tmuxp._internal` (#897)
 
 ## tmuxp 1.33.0 (2023-12-21)
 
diff --git a/docs/api.md b/docs/api.md
index 7e1ac090a0..eb8c67a595 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -110,7 +110,7 @@ If you need an internal API stabilized please [file an issue](https://github.com
 ## Configuration reader
 
 ```{eval-rst}
-.. automodule:: tmuxp.config_reader
+.. automodule:: tmuxp._internal.config_reader
 ```
 
 ## Workspace Builder
diff --git a/src/tmuxp/_internal/__init__.py b/src/tmuxp/_internal/__init__.py
new file mode 100644
index 0000000000..01dccbcfcb
--- /dev/null
+++ b/src/tmuxp/_internal/__init__.py
@@ -0,0 +1,1 @@
+"""Internal APIs for tmuxp."""
diff --git a/src/tmuxp/config_reader.py b/src/tmuxp/_internal/config_reader.py
similarity index 95%
rename from src/tmuxp/config_reader.py
rename to src/tmuxp/_internal/config_reader.py
index 6943aff30d..74f1989acd 100644
--- a/src/tmuxp/config_reader.py
+++ b/src/tmuxp/_internal/config_reader.py
@@ -55,13 +55,13 @@ def load(cls, format: "FormatLiteral", content: str) -> "ConfigReader":
 
         >>> cfg = ConfigReader.load("json", '{ "session_name": "my session" }')
         >>> cfg
-        <tmuxp.config_reader.ConfigReader object at ...>
+        <tmuxp._internal.config_reader.ConfigReader object at ...>
         >>> cfg.content
         {'session_name': 'my session'}
 
         >>> cfg = ConfigReader.load("yaml", 'session_name: my session')
         >>> cfg
-        <tmuxp.config_reader.ConfigReader object at ...>
+        <tmuxp._internal.config_reader.ConfigReader object at ...>
         >>> cfg.content
         {'session_name': 'my session'}
         """
@@ -133,7 +133,7 @@ def from_file(cls, path: pathlib.Path) -> "ConfigReader":
 
         >>> cfg = ConfigReader.from_file(yaml_file)
         >>> cfg
-        <tmuxp.config_reader.ConfigReader object at ...>
+        <tmuxp._internal.config_reader.ConfigReader object at ...>
 
         >>> cfg.content
         {'session_name': 'my session'}
@@ -150,7 +150,7 @@ def from_file(cls, path: pathlib.Path) -> "ConfigReader":
 
         >>> cfg = ConfigReader.from_file(json_file)
         >>> cfg
-        <tmuxp.config_reader.ConfigReader object at ...>
+        <tmuxp._internal.config_reader.ConfigReader object at ...>
 
         >>> cfg.content
         {'session_name': 'my session'}
diff --git a/src/tmuxp/cli/convert.py b/src/tmuxp/cli/convert.py
index 88d995d67d..75a09ab98d 100644
--- a/src/tmuxp/cli/convert.py
+++ b/src/tmuxp/cli/convert.py
@@ -4,7 +4,7 @@
 import pathlib
 import typing as t
 
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.workspace.finders import find_workspace_file, get_workspace_dir
 
 from .. import exc
diff --git a/src/tmuxp/cli/freeze.py b/src/tmuxp/cli/freeze.py
index f82dbb1032..e36795fa18 100644
--- a/src/tmuxp/cli/freeze.py
+++ b/src/tmuxp/cli/freeze.py
@@ -7,7 +7,7 @@
 
 from libtmux.server import Server
 
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.exc import TmuxpException
 from tmuxp.workspace.finders import get_workspace_dir
 
diff --git a/src/tmuxp/cli/import_config.py b/src/tmuxp/cli/import_config.py
index 70f4bf71f5..8bab8d918a 100644
--- a/src/tmuxp/cli/import_config.py
+++ b/src/tmuxp/cli/import_config.py
@@ -5,7 +5,7 @@
 import sys
 import typing as t
 
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.workspace.finders import find_workspace_file
 
 from ..workspace import importers
diff --git a/src/tmuxp/cli/load.py b/src/tmuxp/cli/load.py
index 4311e87efc..7f426938e4 100644
--- a/src/tmuxp/cli/load.py
+++ b/src/tmuxp/cli/load.py
@@ -14,7 +14,8 @@
 
 from tmuxp.types import StrPath
 
-from .. import config_reader, exc, log, util
+from .. import exc, log, util
+from .._internal import config_reader
 from ..workspace import loader
 from ..workspace.builder import WorkspaceBuilder
 from ..workspace.finders import find_workspace_file, get_workspace_dir
diff --git a/src/tmuxp/workspace/builder.py b/src/tmuxp/workspace/builder.py
index 4fb6f7c60d..0efa22f150 100644
--- a/src/tmuxp/workspace/builder.py
+++ b/src/tmuxp/workspace/builder.py
@@ -97,7 +97,7 @@ class WorkspaceBuilder:
 
     1. Load JSON / YAML file via via :class:`pathlib.Path`::
 
-           from tmuxp import config_reader
+           from tmuxp._internal import config_reader
            session_config = config_reader.ConfigReader._load(raw_yaml)
 
        The reader automatically detects the file type from :attr:`pathlib.suffix`.
@@ -105,7 +105,7 @@ class WorkspaceBuilder:
        We can also parse raw file::
 
            import pathlib
-           from tmuxp import config_reader
+           from tmuxp._internal import config_reader
 
            session_config = config_reader.ConfigReader._from_file(
                pathlib.Path('path/to/config.yaml')


Test patch:
diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py
index 5071032771..91a95a2cfb 100644
--- a/tests/cli/test_cli.py
+++ b/tests/cli/test_cli.py
@@ -9,10 +9,10 @@
 from libtmux.server import Server
 
 from tmuxp import cli
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.cli.import_config import get_teamocil_dir, get_tmuxinator_dir
 from tmuxp.cli.load import _reattach, load_plugins
 from tmuxp.cli.utils import tmuxp_echo
-from tmuxp.config_reader import ConfigReader
 from tmuxp.workspace import loader
 from tmuxp.workspace.builder import WorkspaceBuilder
 from tmuxp.workspace.finders import find_workspace_file
diff --git a/tests/cli/test_freeze.py b/tests/cli/test_freeze.py
index 96ca742d7d..0c4637b45a 100644
--- a/tests/cli/test_freeze.py
+++ b/tests/cli/test_freeze.py
@@ -8,7 +8,7 @@
 from libtmux.server import Server
 
 from tmuxp import cli
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 
 
 @pytest.mark.parametrize(
diff --git a/tests/cli/test_load.py b/tests/cli/test_load.py
index 13f7d100c6..a54c97e0b0 100644
--- a/tests/cli/test_load.py
+++ b/tests/cli/test_load.py
@@ -12,13 +12,13 @@
 from pytest_mock import MockerFixture
 
 from tmuxp import cli
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.cli.load import (
     _load_append_windows_to_current_session,
     _load_attached,
     load_plugins,
     load_workspace,
 )
-from tmuxp.config_reader import ConfigReader
 from tmuxp.workspace import loader
 from tmuxp.workspace.builder import WorkspaceBuilder
 
diff --git a/tests/workspace/test_builder.py b/tests/workspace/test_builder.py
index 24a00b0603..42aa931f8e 100644
--- a/tests/workspace/test_builder.py
+++ b/tests/workspace/test_builder.py
@@ -18,8 +18,8 @@
 from libtmux.window import Window
 
 from tmuxp import exc
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.cli.load import load_plugins
-from tmuxp.config_reader import ConfigReader
 from tmuxp.workspace import loader
 from tmuxp.workspace.builder import WorkspaceBuilder
 
diff --git a/tests/workspace/test_config.py b/tests/workspace/test_config.py
index db3023dcaf..42802a113d 100644
--- a/tests/workspace/test_config.py
+++ b/tests/workspace/test_config.py
@@ -5,7 +5,7 @@
 import pytest
 
 from tmuxp import exc
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.workspace import loader, validation
 
 from ..constants import EXAMPLE_PATH
diff --git a/tests/workspace/test_freezer.py b/tests/workspace/test_freezer.py
index 1447b7f4d1..f6ae0c94f2 100644
--- a/tests/workspace/test_freezer.py
+++ b/tests/workspace/test_freezer.py
@@ -5,7 +5,7 @@
 
 from libtmux.session import Session
 
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.workspace import freezer, validation
 from tmuxp.workspace.builder import WorkspaceBuilder
 
diff --git a/tests/workspace/test_import_teamocil.py b/tests/workspace/test_import_teamocil.py
index f7d1f2dfa4..7bbe045ca0 100644
--- a/tests/workspace/test_import_teamocil.py
+++ b/tests/workspace/test_import_teamocil.py
@@ -3,7 +3,7 @@
 
 import pytest
 
-from tmuxp import config_reader
+from tmuxp._internal import config_reader
 from tmuxp.workspace import importers, validation
 
 from ..fixtures import import_teamocil as fixtures
diff --git a/tests/workspace/test_import_tmuxinator.py b/tests/workspace/test_import_tmuxinator.py
index f478312c5b..48a6e3761c 100644
--- a/tests/workspace/test_import_tmuxinator.py
+++ b/tests/workspace/test_import_tmuxinator.py
@@ -3,7 +3,7 @@
 
 import pytest
 
-from tmuxp.config_reader import ConfigReader
+from tmuxp._internal.config_reader import ConfigReader
 from tmuxp.workspace import importers, validation
 
 from ..fixtures import import_tmuxinator as fixtures