Skip to content

Commit 9246fc9

Browse files
fix: Add default dict to run_discovery_script_file (#873)
Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com>
1 parent f0f2c88 commit 9246fc9

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/ansys/geometry/core/modeler.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def __repr__(self) -> str:
304304

305305
@protect_grpc
306306
def run_discovery_script_file(
307-
self, file_path: str, script_args: Dict[str, str], import_design=False
307+
self, file_path: str, script_args: Optional[Dict[str, str]] = None, import_design=False
308308
) -> Tuple[Dict[str, str], Optional["Design"]]:
309309
"""
310310
Run a Discovery script file.
@@ -318,13 +318,14 @@ def run_discovery_script_file(
318318
----------
319319
file_path : str
320320
Path of the file. The extension of the file must be included.
321-
script_args : dict[str, str]
322-
Arguments to pass to the script.
323-
import_design : bool, default: False
321+
script_args : Optional[Dict[str, str]], optional.
322+
Arguments to pass to the script. By default, ``None``.
323+
import_design : bool, optional.
324324
Whether to refresh the current design from the service. When the script
325325
is expected to modify the existing design, set this to ``True`` to retrieve
326326
up-to-date design data. When this is set to ``False`` (default) and the
327-
script modifies the current design, the design may be out-of-sync.
327+
script modifies the current design, the design may be out-of-sync. By default,
328+
``False``.
328329
329330
Returns
330331
-------

tests/integration/test_runscript.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333

3434
# Python (.py)
3535
def test_python_simple_script(modeler: Modeler, skip_not_on_linux_service):
36-
args = {}
3736
result = modeler.run_discovery_script_file(
38-
"./tests/integration/files/disco_scripts/simple_script.py", args
37+
"./tests/integration/files/disco_scripts/simple_script.py"
3938
)
4039
pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE)
4140
pattern_doc = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.Document", re.IGNORECASE)
@@ -45,10 +44,9 @@ def test_python_simple_script(modeler: Modeler, skip_not_on_linux_service):
4544

4645

4746
def test_python_failing_script(modeler: Modeler, skip_not_on_linux_service):
48-
args = {}
4947
with pytest.raises(GeometryRuntimeError):
5048
modeler.run_discovery_script_file(
51-
"./tests/integration/files/disco_scripts/failing_script.py", args
49+
"./tests/integration/files/disco_scripts/failing_script.py"
5250
)
5351

5452

@@ -73,9 +71,8 @@ def test_python_integrated_script(modeler: Modeler, skip_not_on_linux_service):
7371

7472
# SpaceClaim (.scscript)
7573
def test_scscript_simple_script(modeler: Modeler, skip_not_on_linux_service):
76-
args = {}
7774
result = modeler.run_discovery_script_file(
78-
"./tests/integration/files/disco_scripts/simple_script.scscript", args
75+
"./tests/integration/files/disco_scripts/simple_script.scscript"
7976
)
8077
assert len(result) == 2
8178
pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE)
@@ -87,9 +84,8 @@ def test_scscript_simple_script(modeler: Modeler, skip_not_on_linux_service):
8784

8885
# Discovery (.dscript)
8986
def test_dscript_simple_script(modeler: Modeler, skip_not_on_linux_service):
90-
args = {}
9187
result = modeler.run_discovery_script_file(
92-
"./tests/integration/files/disco_scripts/simple_script.dscript", args
88+
"./tests/integration/files/disco_scripts/simple_script.dscript"
9389
)
9490
assert len(result) == 2
9591
pattern_db = re.compile(r"SpaceClaim\.Api\.[A-Za-z0-9]+\.DesignBody", re.IGNORECASE)

0 commit comments

Comments
 (0)