Skip to content

Commit 2e60dc8

Browse files
committed
Make WorkElement attributes explicitly native str type.
Make WorkElement.namespace and WorkElement.operation constant member properties that are initialized as native str whether the client initializes through the constructor or the class deserialize(). Refs #228
1 parent d0ee013 commit 2e60dc8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/gmx/workflow.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,10 @@ def __repr__(self):
397397
class WorkElement(object):
398398
"""Encapsulate an element of a work specification."""
399399
def __init__(self, namespace="gmxapi", operation=None, params=None, depends=()):
400-
self.namespace = to_string(namespace)
400+
self._namespace = str(to_string(namespace))
401401
# We can add an operations submodule to validate these. E.g. self.operation = gmx.workflow.operations.normalize(operation)
402402
if operation is not None:
403-
self.operation = to_string(operation)
403+
self._operation = str(to_string(operation))
404404
else:
405405
raise exceptions.UsageError("Invalid argument type for operation.")
406406

@@ -423,6 +423,16 @@ def __init__(self, namespace="gmxapi", operation=None, params=None, depends=()):
423423
self._name = None
424424
self._workspec = None
425425

426+
@property
427+
def namespace(self):
428+
assert isinstance(self._namespace, str)
429+
return self._namespace
430+
431+
@property
432+
def operation(self):
433+
assert isinstance(self._operation, str)
434+
return self._operation
435+
426436
@property
427437
def name(self):
428438
assert isinstance(self._name, (str, type(None)))

0 commit comments

Comments
 (0)