Skip to content

Commit d4dcfae

Browse files
committed
Simplify the usage of padding function
1 parent 2ca21f6 commit d4dcfae

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

linodecli/configuration/helpers.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,14 @@ def _default_thing_input(
144144
exists = current_value is not None
145145

146146
idx_offset = int(exists) + 1
147-
pad = partial(_calculate_padding, total=len(things) + idx_offset)
147+
pad = partial(_pad_index, total=len(things) + idx_offset)
148148

149149
# If there is a current value, users should have the option to clear it
150150
if exists:
151-
print(f"{pad(1)}1 - No Default")
151+
print(f"{pad(1)} - No Default")
152152

153153
for ind, thing in enumerate(things):
154-
effective_ind = ind + idx_offset
155-
print(f"{pad(effective_ind)}{effective_ind} - {thing}")
154+
print(f"{pad(ind + idx_offset)} - {thing}")
156155
print()
157156

158157
while True:
@@ -188,11 +187,11 @@ def _default_thing_input(
188187
return things[choice_idx]
189188

190189

191-
def _calculate_padding(idx: int, total: int) -> str:
190+
def _pad_index(idx: int, total: int) -> str:
192191
max_padding = math.floor(math.log10(total)) + 1
193192
num_spaces = max_padding - math.floor(math.log10(idx))
194193

195-
return " " * num_spaces
194+
return " " * num_spaces + str(idx)
196195

197196

198197
def _default_text_input(

0 commit comments

Comments
 (0)