-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a reusable function to check Enum membership.
- Loading branch information
Showing
4 changed files
with
47 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/functional/i/invalid/invalid_name/invalid_name_enum.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
""" Tests for invalid-name checker in the context of enums. """ | ||
# pylint: disable=too-few-public-methods | ||
|
||
|
||
from enum import Enum | ||
|
||
|
||
class JustARegularClass: | ||
""" No `invalid-name` by default for class attributes | ||
""" | ||
apple = 42 | ||
orange = 24 | ||
|
||
|
||
class EnumClass(Enum): | ||
""" Members of a subclass of `enum.Enum` are expected to be UPPERCASE. | ||
""" | ||
apple = 42 # [invalid-name] | ||
orange = 24 # [invalid-name] | ||
PEAR = 1 |
2 changes: 2 additions & 0 deletions
2
tests/functional/i/invalid/invalid_name/invalid_name_enum.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invalid-name:19:4:19:9:EnumClass:"Class constant name ""apple"" doesn't conform to UPPER_CASE naming style":HIGH | ||
invalid-name:20:4:20:10:EnumClass:"Class constant name ""orange"" doesn't conform to UPPER_CASE naming style":HIGH |