Skip to content

Commit eec3993

Browse files
oscar-LTethanfurman
authored andcommitted
Check Incrementable instead of type checking
1 parent 61ac223 commit eec3993

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Lib/enum.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,12 +1214,15 @@ def _generate_next_value_(name, start, count, last_values):
12141214
count: the number of existing members
12151215
last_value: the last value assigned or None
12161216
"""
1217-
numerical_last_values = [x for x in last_values if isinstance(x, int) or isinstance(x, float)]
1218-
for last_value in sorted(numerical_last_values, reverse=True):
1217+
incrementable_last_values = []
1218+
for val in last_values:
12191219
try:
1220-
return last_value + 1
1220+
incrementable_last_values.append(val + 1)
12211221
except TypeError:
12221222
pass
1223+
1224+
if incrementable_last_values:
1225+
return sorted(incrementable_last_values)[-1]
12231226
else:
12241227
return start
12251228

0 commit comments

Comments
 (0)