Skip to content

Checks your python enums. Eliminates common attribute errors and name conflicts.

License

Notifications You must be signed in to change notification settings

SuadeLabs/enumchecker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enumchecker

Checks your python enums. Eliminates common attribute errors and name conflicts.

Usage

Enumchecker checks for common mistakes with enums, including conflicting class definitions and the use of enums that don't exist. For example:

from enum import Enum

class MyEnum(Enum):
    a = "a"
    b = "b"

def check(x):
    if x == MyEnum.c:  # <- AttributeError
        print("x was 'c'")

You can call the script directly via python enumchecker.py --dirname <dir>, to check all files in a directory. Alternatively, once installed, you can invoke the enumchecker command.

Implementation notes

The script enumchecker.py is a good resource for learning about python's ast module. It searches through class definitions and looks for subclasses of the Enum class. It's not foolproof - by reading the source code you can probably think of a few ways to fool it!

About

Checks your python enums. Eliminates common attribute errors and name conflicts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages