@@ -127,23 +127,29 @@ class Alias:
127
127
Examples
128
128
--------
129
129
>>> par = Alias((3.0, 3.0), prefix="+o", separator="/")
130
- >>> par.value
130
+ >>> par._value
131
131
'+o3.0/3.0'
132
132
133
133
>>> par = Alias(["xaf", "yaf", "WSen"])
134
- >>> par.value
134
+ >>> par._value
135
135
['xaf', 'yaf', 'WSen']
136
136
"""
137
137
138
- def __init__ (
139
- self ,
140
- value : Any ,
141
- prefix : str = "" ,
142
- separator : Literal ["/" , "," ] | None = None ,
143
- mapping : bool | Mapping = False ,
144
- ):
145
- self .value = to_string (
146
- value = value , prefix = prefix , separator = separator , mapping = mapping
138
+ value : Any
139
+ prefix : str = ""
140
+ separator : Literal ["/" , "," ] | None = None
141
+ mapping : bool | Mapping = False
142
+
143
+ @property
144
+ def _value (self ) -> str | Sequence [str ] | None :
145
+ """
146
+ The value of the alias as a string, a sequence of strings or None.
147
+ """
148
+ return to_string (
149
+ value = self .value ,
150
+ prefix = self .prefix ,
151
+ separator = self .separator ,
152
+ mapping = self .mapping ,
147
153
)
148
154
149
155
@@ -221,13 +227,13 @@ def kwdict(self):
221
227
for option , aliases in self .options .items ():
222
228
for alias in aliases :
223
229
# value can be a string, a sequence of strings or None.
224
- if alias .value is None :
230
+ if alias ._value is None :
225
231
continue
226
232
# Special handing of repeatable parameter like -B/frame.
227
- if is_nonstr_iter (alias .value ):
228
- kwdict [option ] = alias .value
233
+ if is_nonstr_iter (alias ._value ):
234
+ kwdict [option ] = alias ._value
229
235
# A repeatable option should have only one alias, so break.
230
236
break
231
237
232
- kwdict [option ] += alias .value
238
+ kwdict [option ] += alias ._value
233
239
return kwdict
0 commit comments