Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mypyc/irbuild/classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def populate_non_ext_bases(builder: IRBuilder, cdef: ClassDef) -> Value:
is_named_tuple = cdef.info.is_named_tuple
ir = builder.mapper.type_to_ir[cdef.info]
bases = []
for cls in cdef.info.mro[1:]:
for cls in (b.type for b in cdef.info.bases):
if cls.fullname == "builtins.object":
continue
if is_named_tuple and cls.fullname in (
Expand Down Expand Up @@ -682,7 +682,7 @@ def add_non_ext_class_attr(
# are final.
if (
cdef.info.bases
and cdef.info.bases[0].type.fullname == "enum.Enum"
and cdef.info.bases[0].type.is_enum
# Skip these since Enum will remove it
and lvalue.name not in EXCLUDED_ENUM_ATTRIBUTES
):
Expand Down
12 changes: 12 additions & 0 deletions mypyc/test-data/run-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -2619,3 +2619,15 @@ def test_final_attribute() -> None:
assert C.a['x'] == 'y'
assert C.b['x'] == 'y'
assert C.a is C.b

[case testClassDerivedFromIntEnum]
from enum import IntEnum, auto

class Player(IntEnum):
MIN = auto()

print(f'{Player.MIN = }')
[file driver.py]
from native import Player
[out]
Player.MIN = <Player.MIN: 1>