File tree Expand file tree Collapse file tree 3 files changed +18
-18
lines changed Expand file tree Collapse file tree 3 files changed +18
-18
lines changed Original file line number Diff line number Diff line change 3
3
import inquirer # noqa
4
4
5
5
choices_hints = {
6
- "Jumbo" : "The biggest one we have" ,
7
- "Large" : "If you need the extra kick" ,
8
6
"Standard" : "For your every day use" ,
7
+ "Large" : "If you need the extra kick" ,
8
+ "Jumbo" : "The biggest one we have" ,
9
9
}
10
10
11
11
questions = [
Original file line number Diff line number Diff line change 12
12
13
13
14
14
class TaggedValue :
15
- def __init__ (self , choice ):
16
- self .label = choice [ 0 ]
17
- self .tag = choice [ 1 ]
18
- self ._hash = hash ( choice )
15
+ def __init__ (self , tag , value ):
16
+ self .tag = tag
17
+ self .value = value
18
+ self .tuple = ( tag , value )
19
19
20
20
def __str__ (self ):
21
- return self .label
21
+ return self .tag
22
22
23
23
def __repr__ (self ):
24
- return repr (self .tag )
24
+ return repr (self .value )
25
25
26
26
def __eq__ (self , other ):
27
27
if isinstance (other , TaggedValue ):
28
- return other .tag == self .tag
28
+ return other .value == self .value
29
29
if isinstance (other , tuple ):
30
- return other == ( self .label , self . tag )
31
- return other == self .tag
30
+ return other == self .tuple
31
+ return other == self .value
32
32
33
33
def __ne__ (self , other ):
34
34
return not self .__eq__ (other )
35
35
36
36
def __hash__ (self ) -> int :
37
- return self ._hash
37
+ return hash ( self .tuple )
38
38
39
39
40
40
class Question :
@@ -93,7 +93,7 @@ def default(self):
93
93
@property
94
94
def choices_generator (self ):
95
95
for choice in self ._solve (self ._choices ):
96
- yield (TaggedValue (choice ) if isinstance (choice , tuple ) and len (choice ) == 2 else choice )
96
+ yield (TaggedValue (* choice ) if isinstance (choice , tuple ) and len (choice ) == 2 else choice )
97
97
98
98
@property
99
99
def choices (self ):
Original file line number Diff line number Diff line change @@ -354,16 +354,16 @@ def test_default_value_validation(self):
354
354
355
355
def test_tagged_value ():
356
356
LABEL = "label"
357
- TAG = "l"
358
- tp = (LABEL , TAG )
359
- tv = questions .TaggedValue (tp )
357
+ VALUE = "l"
358
+ tp = (LABEL , VALUE )
359
+ tv = questions .TaggedValue (* tp )
360
360
361
361
assert (str (tv ) == str (LABEL )) is True
362
- assert (repr (tv ) == repr (TAG )) is True
362
+ assert (repr (tv ) == repr (VALUE )) is True
363
363
assert (hash (tv ) == hash (tp )) is True
364
364
365
365
assert (tv == tv ) is True
366
366
assert (tv != tv ) is False
367
367
assert (tv == tp ) is True
368
- assert (tv == TAG ) is True
368
+ assert (tv == VALUE ) is True
369
369
assert (tv == "" ) is False
You can’t perform that action at this time.
0 commit comments