Skip to content

Commit ba77831

Browse files
committed
chore(mypy): Typings for plugin tests
1 parent 28d54c9 commit ba77831

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

tests/fixtures/pluginsystem/partials/all_pass.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import typing as t
2+
13
from .test_plugin_helpers import MyTestTmuxpPlugin
24

5+
if t.TYPE_CHECKING:
6+
from ._types import PluginTestConfigSchema
7+
38

49
class AllVersionPassPlugin(MyTestTmuxpPlugin):
510
def __init__(self) -> None:
6-
config = {
11+
config: "PluginTestConfigSchema" = {
712
"plugin_name": "tmuxp-plugin-my-tmuxp-plugin",
813
"tmux_min_version": "1.8",
914
"tmux_max_version": "100.0",

tests/fixtures/pluginsystem/partials/libtmux_version_fail.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import typing as t
2+
13
from .test_plugin_helpers import MyTestTmuxpPlugin
24

5+
if t.TYPE_CHECKING:
6+
from ._types import PluginTestConfigSchema
7+
38

49
class LibtmuxVersionFailMinPlugin(MyTestTmuxpPlugin):
510
def __init__(self) -> None:
6-
config: dict[str, str] = {
11+
config: "PluginTestConfigSchema" = {
712
"plugin_name": "libtmux-min-version-fail",
813
"libtmux_min_version": "0.8.3",
914
"libtmux_version": "0.7.0",
@@ -13,7 +18,7 @@ def __init__(self) -> None:
1318

1419
class LibtmuxVersionFailMaxPlugin(MyTestTmuxpPlugin):
1520
def __init__(self) -> None:
16-
config: dict[str, str] = {
21+
config: "PluginTestConfigSchema" = {
1722
"plugin_name": "libtmux-max-version-fail",
1823
"libtmux_max_version": "3.0",
1924
"libtmux_version": "3.5",
@@ -23,7 +28,7 @@ def __init__(self) -> None:
2328

2429
class LibtmuxVersionFailIncompatiblePlugin(MyTestTmuxpPlugin):
2530
def __init__(self) -> None:
26-
config: dict[str, str | list[str]] = {
31+
config: "PluginTestConfigSchema" = {
2732
"plugin_name": "libtmux-incompatible-version-fail",
2833
"libtmux_version_incompatible": ["0.7.1"],
2934
"libtmux_version": "0.7.1",

tests/fixtures/pluginsystem/partials/test_plugin_helpers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
from tmuxp.plugin import TmuxpPlugin
44

5+
if t.TYPE_CHECKING:
6+
from tmuxp._types import PluginConfigSchema
57

6-
class Config(t.TypedDict):
7-
tmux_version: t.Optional[str]
8-
tmuxp_version: t.Optional[str]
9-
libtmux_version: t.Optional[str]
8+
from ._types import PluginTestConfigSchema
109

1110

1211
class MyTestTmuxpPlugin(TmuxpPlugin):
13-
def __init__(self, config: Config) -> None:
12+
def __init__(self, config: "PluginTestConfigSchema") -> None:
1413
assert isinstance(config, dict)
1514
tmux_version = config.pop("tmux_version", None)
1615
libtmux_version = config.pop("libtmux_version", None)
1716
tmuxp_version = config.pop("tmuxp_version", None)
1817

18+
t.cast("PluginConfigSchema", config)
19+
1920
TmuxpPlugin.__init__(self, **config)
2021

2122
# WARNING! This should not be done in anything but a test

tests/fixtures/pluginsystem/partials/tmux_version_fail.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import typing as t
2+
13
from .test_plugin_helpers import MyTestTmuxpPlugin
24

5+
if t.TYPE_CHECKING:
6+
from ._types import PluginTestConfigSchema
7+
38

49
class TmuxVersionFailMinPlugin(MyTestTmuxpPlugin):
510
def __init__(self) -> None:
6-
config: dict[str, str] = {
11+
config: "PluginTestConfigSchema" = {
712
"plugin_name": "tmux-min-version-fail",
813
"tmux_min_version": "1.8",
914
"tmux_version": "1.7",
@@ -13,7 +18,7 @@ def __init__(self) -> None:
1318

1419
class TmuxVersionFailMaxPlugin(MyTestTmuxpPlugin):
1520
def __init__(self) -> None:
16-
config: dict[str, str] = {
21+
config: "PluginTestConfigSchema" = {
1722
"plugin_name": "tmux-max-version-fail",
1823
"tmux_max_version": "3.0",
1924
"tmux_version": "3.5",
@@ -23,7 +28,7 @@ def __init__(self) -> None:
2328

2429
class TmuxVersionFailIncompatiblePlugin(MyTestTmuxpPlugin):
2530
def __init__(self) -> None:
26-
config: dict[str, str | list[str]] = {
31+
config: "PluginTestConfigSchema" = {
2732
"plugin_name": "tmux-incompatible-version-fail",
2833
"tmux_version_incompatible": ["2.3"],
2934
"tmux_version": "2.3",

tests/fixtures/pluginsystem/partials/tmuxp_version_fail.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import typing as t
2+
13
from .test_plugin_helpers import MyTestTmuxpPlugin
24

5+
if t.TYPE_CHECKING:
6+
from ._types import PluginTestConfigSchema
7+
38

49
class TmuxpVersionFailMinPlugin(MyTestTmuxpPlugin):
510
def __init__(self) -> None:
6-
config: dict[str, str] = {
11+
config: "PluginTestConfigSchema" = {
712
"plugin_name": "tmuxp-min-version-fail",
813
"tmuxp_min_version": "1.7.0",
914
"tmuxp_version": "1.6.3",
@@ -13,7 +18,7 @@ def __init__(self) -> None:
1318

1419
class TmuxpVersionFailMaxPlugin(MyTestTmuxpPlugin):
1520
def __init__(self) -> None:
16-
config: dict[str, str] = {
21+
config: "PluginTestConfigSchema" = {
1722
"plugin_name": "tmuxp-max-version-fail",
1823
"tmuxp_max_version": "2.0.0",
1924
"tmuxp_version": "2.5",
@@ -23,7 +28,7 @@ def __init__(self) -> None:
2328

2429
class TmuxpVersionFailIncompatiblePlugin(MyTestTmuxpPlugin):
2530
def __init__(self) -> None:
26-
config: dict[str, str | list[str]] = {
31+
config: "PluginTestConfigSchema" = {
2732
"plugin_name": "tmuxp-incompatible-version-fail",
2833
"tmuxp_version_incompatible": ["1.5.0"],
2934
"tmuxp_version": "1.5.0",

0 commit comments

Comments
 (0)