Skip to content

Commit 4ea618a

Browse files
authored
Merge pull request #5 from disguise-one/update_api_naming
Add new pystub proxy support
2 parents 3f33f62 + c022a39 commit 4ea618a

File tree

8 files changed

+31
-29
lines changed

8 files changed

+31
-29
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.0] - 2026-01-06
9+
10+
### Changed
11+
- `d3_api_plugin` has been renamed to `d3_api_execute`.
12+
- `d3_api_aplugin` has been renamed to `d3_api_aexecute`.
13+
- Updated documentation to reflect `pystub` proxy support.
14+
815
## [1.2.0] - 2025-12-02
916

1017
### Added

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ To enable IDE autocomplete and type checking for Designer's Python API, install
8383
pip install designer-plugin-pystub
8484
```
8585

86-
Once installed, import the stubs using the `TYPE_CHECKING` pattern. This provides type hints in your IDE without affecting runtime execution:
86+
Once installed, import the stubs.
87+
> **Important:** `pystub` provides type hints for Designer's API objects but not their implementations. These objects only exist in Designer's runtime and cannot be used in local Python code. They must only be referenced in code that will be executed remotely in Designer.
88+
8789
```python
88-
from typing import TYPE_CHECKING
89-
if TYPE_CHECKING:
90-
from designer_plugin.pystub.d3 import *
90+
from designer_plugin.pystub import *
9191
```
9292

9393
This allows you to get autocomplete for Designer objects like `resourceManager`, `Screen2`, `Path`, etc., while writing your plugin code.
@@ -100,9 +100,7 @@ The Client API allows you to define a class with methods that execute remotely o
100100

101101
```python
102102
from designer_plugin.d3sdk import D3PluginClient
103-
from typing import TYPE_CHECKING
104-
if TYPE_CHECKING:
105-
from designer_plugin.pystub.d3 import *
103+
from designer_plugin.pystub import *
106104

107105
# 1. Sync example -----------------------------------
108106
class MySyncPlugin(D3PluginClient):
@@ -186,9 +184,7 @@ Both `D3AsyncSession` and `D3Session` provide two methods for executing function
186184

187185
```python
188186
from designer_plugin.d3sdk import d3pythonscript, d3function, D3AsyncSession
189-
from typing import TYPE_CHECKING
190-
if TYPE_CHECKING:
191-
from designer_plugin.pystub.d3 import *
187+
from designer_plugin.pystub import *
192188

193189
# 1. @d3pythonscript - simple one-off execution
194190
@d3pythonscript
@@ -251,4 +247,3 @@ logging.getLogger('designer_plugin').setLevel(logging.DEBUG)
251247
# License
252248

253249
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
254-

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "designer-plugin"
7-
version = "1.2.1"
7+
version = "1.3.0"
88
description = "Python library for creating Disguise Designer plugins with DNS-SD discovery and remote Python execution"
99
authors = [
1010
{ name = "Tom Whittock", email = "tom.whittock@disguise.one" },

src/designer_plugin/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async def d3_api_arequest(
125125

126126
###############################################################################
127127
# API async interface
128-
async def d3_api_aplugin(
128+
async def d3_api_aexecute(
129129
hostname: str,
130130
port: int,
131131
payload: PluginPayload[RetType],
@@ -219,7 +219,7 @@ async def d3_api_aregister_module(
219219

220220
###############################################################################
221221
# API sync interface
222-
def d3_api_plugin(
222+
def d3_api_execute(
223223
hostname: str,
224224
port: int,
225225
payload: PluginPayload[RetType],

src/designer_plugin/d3sdk/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from typing import Any, ParamSpec, TypeVar
1414

1515
from designer_plugin.api import (
16-
d3_api_aplugin,
16+
d3_api_aexecute,
1717
d3_api_aregister_module,
18-
d3_api_plugin,
18+
d3_api_execute,
1919
d3_api_register_module,
2020
)
2121
from designer_plugin.d3sdk.ast_utils import (
@@ -112,7 +112,7 @@ async def async_wrapper(self, *args, **kwargs): # type: ignore
112112
session_runtime_error_message(self.__class__.__name__)
113113
)
114114
payload = build_payload(self, method_name, positional, keyword)
115-
response: PluginResponse[T] = await d3_api_aplugin(
115+
response: PluginResponse[T] = await d3_api_aexecute(
116116
self._hostname, self._port, payload
117117
)
118118
return response.returnValue
@@ -130,7 +130,7 @@ def sync_wrapper(self, *args, **kwargs): # type: ignore
130130
session_runtime_error_message(self.__class__.__name__)
131131
)
132132
payload = build_payload(self, method_name, positional, keyword)
133-
response: PluginResponse[T] = d3_api_plugin(
133+
response: PluginResponse[T] = d3_api_execute(
134134
self._hostname, self._port, payload
135135
)
136136
return response.returnValue

src/designer_plugin/d3sdk/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
from designer_plugin.api import (
1111
Method,
12-
d3_api_aplugin,
12+
d3_api_aexecute,
1313
d3_api_aregister_module,
1414
d3_api_arequest,
15-
d3_api_plugin,
15+
d3_api_execute,
1616
d3_api_register_module,
1717
d3_api_request,
1818
)
@@ -117,7 +117,7 @@ def execute(
117117
Raises:
118118
PluginException: If the plugin execution fails.
119119
"""
120-
return d3_api_plugin(self.hostname, self.port, payload, timeout_sec)
120+
return d3_api_execute(self.hostname, self.port, payload, timeout_sec)
121121

122122
def request(self, method: Method, url_endpoint: str, **kwargs: Any) -> Any:
123123
"""Make a generic HTTP request to Designer API.
@@ -270,7 +270,7 @@ async def execute(
270270
Raises:
271271
PluginException: If the plugin execution fails.
272272
"""
273-
return await d3_api_aplugin(self.hostname, self.port, payload, timeout_sec)
273+
return await d3_api_aexecute(self.hostname, self.port, payload, timeout_sec)
274274

275275
async def register_module(
276276
self, module_name: str, timeout_sec: float | None = None

tests/test_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_method_call_without_session_raises_error(self, plugin):
7171

7272
def test_correct_arguments_sync(self, plugin, mock_response):
7373
"""Test that correct arguments pass through successfully."""
74-
with patch('designer_plugin.d3sdk.client.d3_api_plugin', return_value=mock_response) as mock_api:
74+
with patch('designer_plugin.d3sdk.client.d3_api_execute', return_value=mock_response) as mock_api:
7575
plugin._hostname = "localhost"
7676
plugin._port = 80
7777

@@ -114,7 +114,7 @@ def test_unexpected_keyword_argument(self, plugin):
114114

115115
def test_method_with_defaults_partial_args(self, plugin, mock_response):
116116
"""Test method with default parameters using partial arguments."""
117-
with patch('designer_plugin.d3sdk.client.d3_api_plugin', return_value=mock_response):
117+
with patch('designer_plugin.d3sdk.client.d3_api_execute', return_value=mock_response):
118118
plugin._hostname = "localhost"
119119
plugin._port = 80
120120

@@ -124,7 +124,7 @@ def test_method_with_defaults_partial_args(self, plugin, mock_response):
124124

125125
def test_method_with_defaults_override(self, plugin, mock_response):
126126
"""Test method with default parameters overriding defaults."""
127-
with patch('designer_plugin.d3sdk.client.d3_api_plugin', return_value=mock_response):
127+
with patch('designer_plugin.d3sdk.client.d3_api_execute', return_value=mock_response):
128128
plugin._hostname = "localhost"
129129
plugin._port = 80
130130

@@ -134,7 +134,7 @@ def test_method_with_defaults_override(self, plugin, mock_response):
134134

135135
def test_method_with_defaults_keyword(self, plugin, mock_response):
136136
"""Test method with default parameters using keyword arguments."""
137-
with patch('designer_plugin.d3sdk.client.d3_api_plugin', return_value=mock_response):
137+
with patch('designer_plugin.d3sdk.client.d3_api_execute', return_value=mock_response):
138138
plugin._hostname = "localhost"
139139
plugin._port = 80
140140

@@ -144,7 +144,7 @@ def test_method_with_defaults_keyword(self, plugin, mock_response):
144144

145145
def test_keyword_only_parameters(self, plugin, mock_response):
146146
"""Test method with keyword-only parameters."""
147-
with patch('designer_plugin.d3sdk.client.d3_api_plugin', return_value=mock_response):
147+
with patch('designer_plugin.d3sdk.client.d3_api_execute', return_value=mock_response):
148148
plugin._hostname = "localhost"
149149
plugin._port = 80
150150

@@ -162,7 +162,7 @@ def test_keyword_only_parameters_as_positional_fails(self, plugin):
162162

163163
def test_mixed_parameters(self, plugin, mock_response):
164164
"""Test method with mixed parameter types."""
165-
with patch('designer_plugin.d3sdk.client.d3_api_plugin', return_value=mock_response):
165+
with patch('designer_plugin.d3sdk.client.d3_api_execute', return_value=mock_response):
166166
plugin._hostname = "localhost"
167167
plugin._port = 80
168168

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)