types(workspace-imports) Example typings via `NotRequried` by tony · Pull Request #981 · tmux-python/tmuxp · GitHub
Skip to content
Open
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
61 changes: 61 additions & 0 deletions src/tmuxp/_internal/types.py
8 changes: 6 additions & 2 deletions src/tmuxp/cli/import_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

CLIColorModeLiteral: TypeAlias = t.Literal["auto", "always", "never"]

from tmuxp._internal.types import WorkspaceConfig


def get_tmuxinator_dir() -> pathlib.Path:
"""Return tmuxinator configuration directory.
Expand Down Expand Up @@ -160,7 +162,7 @@ def create_import_subparser(
class ImportConfigFn(t.Protocol):
"""Typing for import configuration callback function."""

def __call__(self, workspace_dict: dict[str, t.Any]) -> dict[str, t.Any]:
def __call__(self, workspace_dict: dict[str, t.Any]) -> WorkspaceConfig:
"""Execute tmuxp import function."""
...

Expand All @@ -176,7 +178,9 @@ def import_config(
colors = Colors(ColorMode.AUTO)

existing_workspace_file = ConfigReader._from_file(pathlib.Path(workspace_file))
cfg_reader = ConfigReader(importfunc(existing_workspace_file))
cfg_reader = ConfigReader(
t.cast(dict[t.Any, t.Any], importfunc(existing_workspace_file))
)

workspace_file_format = prompt_choices(
"Convert to",
Expand Down
60 changes: 35 additions & 25 deletions src/tmuxp/workspace/importers.py
Loading