blob: 1b70bbe82df5f470bfc60c598bae8db4b5361104 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
"""Tests for self-defined Enum members (https://github.com/pylint-dev/pylint/issues/6805)"""
# pylint: disable=missing-docstring
# pylint: disable=too-few-public-methods
from enum import IntEnum
class Foo(type):
pass
class Parent:
def __new__(cls, *_args, **_kwargs):
return object.__new__(cls)
class NotEnumHasDynamicGetAttrMetaclass(metaclass=Foo):
def __new__(cls):
return Parent.__new__(cls)
def __getattr__(self, item):
return item
def magic(self):
return self.dynamic
NotEnumHasDynamicGetAttrMetaclass().magic()
class Day(IntEnum):
MONDAY = (1, "Mon")
TUESDAY = (2, "Tue")
WEDNESDAY = (3, "Wed")
THURSDAY = (4, "Thu")
FRIDAY = (5, "Fri")
SATURDAY = (6, "Sat")
SUNDAY = (7, "Sun")
def __new__(cls, value, _abbr=None):
return int.__new__(cls, value)
print(Day.FRIDAY.foo) # [no-member]
|