Skip to content

refactor!: config_reader to tmuxp._internal #897

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

Merged
merged 2 commits into from
Dec 21, 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
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/tmuxp/_internal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Internal APIs for tmuxp."""
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
"""
Expand Down Expand Up @@ -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'}
Expand All @@ -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'}
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/cli/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/cli/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/tmuxp/cli/import_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/tmuxp/workspace/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ 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`.

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')
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/workspace/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/workspace/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/workspace/test_freezer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/workspace/test_import_teamocil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/workspace/test_import_tmuxinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down