Skip to content

Commit f2cc574

Browse files
committed
fix enums created functionally and add comment
1 parent ba435ac commit f2cc574

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mypy/semanal_enum.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ def build_enum_call_typeinfo(
143143
var = Var(item)
144144
var.info = info
145145
var.is_property = True
146+
# When an enum is created by its functional form `Enum(name, values)`
147+
# - if it is a string it is first split by commas/whitespace
148+
# - if it is an iterable of single items each item is assigned a value starting at `start`
149+
# - if it is an iterable of (name, value) then the given values will be used
150+
# either way, each item should be treated as if it has an explicit value.
151+
var.has_explicit_value = True
146152
var._fullname = f"{info.fullname}.{item}"
147153
info.names[item] = SymbolTableNode(MDEF, var)
148154
return info

0 commit comments

Comments
 (0)