Issue 3381: fix WPS115 false-positive on StrEnum, IntEnum, IntFlag at…#3382
Conversation
189aa68 to
bbf3927
Compare
| enum_with_primitive3 = 'class First({0}, EnumMeta): ...' | ||
| enum_with_primitive4 = 'class First({0}, enum.EnumType): ...' | ||
|
|
||
| repr_enum_with_primitive1 = 'class First({0}, enum.StrEnum): ...' |
There was a problem hiding this comment.
Maybe let's use some other name? ReprEnum can be subclassed with a primitive. But, IntEnum can't.
Maybe something like concrete_enum?
There was a problem hiding this comment.
>>> import enum
>>> class A(int, enum.ReprEnum):
... x = 1
... y = 2
...
>>> A.x, A.y
(<A.x: 1>, <A.y: 2>)There was a problem hiding this comment.
renamed
| from wemake_python_styleguide.logic.source import node_to_string | ||
|
|
||
| _ENUM_NAMES: Final = ( | ||
| _REPR_ENUM_NAMES: Final = ( |
There was a problem hiding this comment.
| _REPR_ENUM_NAMES: Final = ( | |
| _CONCRETE_ENUM_NAMES: Final = ( |
There was a problem hiding this comment.
renamed
| 'EnumType', | ||
| 'EnumMeta', | ||
| 'enum.Flag', | ||
| 'Flag', |
There was a problem hiding this comment.
| 'Flag', | |
| 'Flag', | |
| 'enum.ReprEnum', | |
| 'ReprEnum', |
| return any(enum_base in string_bases for enum_base in base_names) | ||
|
|
||
|
|
||
| def has_repr_enum_base(defn: ast.ClassDef) -> bool: |
There was a problem hiding this comment.
removed. but also had to remove has_enum_base cause it is not used any more.
bbf3927 to
e35016a
Compare
| concrete_enum_with_primitive3 = 'class First({0}, IntEnum): ...' | ||
| concrete_enum_with_primitive4 = 'class First({0}, enum.IntEnum): ...' | ||
| concrete_enum_with_primitive5 = 'class First({0}, IntFlag): ...' | ||
| concrete_enum_with_primitive6 = 'class First({0}, enum.IntFlag): ...' |
There was a problem hiding this comment.
Please, also test that class First(PRIMITIVE, TextChoices): ...' and similar is not possible
| def has_regular_enum_base(defn: ast.ClassDef) -> bool: | ||
| """Tells whether some class has `Enum` or similar class as its base. | ||
|
|
||
| Unlike ``has_enum_base`` it excluded `IntEnum`, `StrEnum`, `IntFlag`. |
There was a problem hiding this comment.
please, fix the doc here and in one more place: has_enum_base does not exist anymore.
There was a problem hiding this comment.
fixed. also there was a typo in test name. fixed as well
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3382 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 361 361
Lines 11830 11860 +30
Branches 808 808
=========================================
+ Hits 11830 11860 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1b98149 to
84142a1
Compare
84142a1 to
a6c5331
Compare
…tributes (#3381)
I have made things!
CHANGELOG.mdRelated issues
Closes #3381