diff options
author | Chandan Singh <chandan@chandansingh.net> | 2019-07-16 22:08:28 +0100 |
---|---|---|
committer | Chandan Singh <chandan@chandansingh.net> | 2019-07-16 22:24:19 +0100 |
commit | fa6d9856c86e1fe72af02f4ef32267b66be49c75 (patch) | |
tree | e5f1fc18cb0156891ba011902124e480260481ed | |
parent | fbb8eea8334023e30c8719cb52f9b0e226b4eb8b (diff) | |
download | buildstream-chandan/enums.tar.gz |
types.py: Derive enumerations from standard library classeschandan/enums
`types.py` defines a few enumerations, but only some of them are
derived from the standard `enum.Enum` class.
Among other things, this makes type checking difficult as the inferred
type of the values is `<class 'int'>` or `<class 'str'>`, and not
something like `<enum 'Scope'>`.
Note that `Consistency` is derived from `IntEnum` and not `Enum`, since
it is sometimes used in comparisons.
-rw-r--r-- | src/buildstream/types.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/buildstream/types.py b/src/buildstream/types.py index 6f6262e41..d186c4fba 100644 --- a/src/buildstream/types.py +++ b/src/buildstream/types.py @@ -25,7 +25,7 @@ Foundation types """ -from enum import Enum +from enum import Enum, IntEnum class Scope(Enum): @@ -56,7 +56,7 @@ class Scope(Enum): """ -class Consistency(): +class Consistency(IntEnum): """Defines the various consistency states of a :class:`.Source`. """ @@ -81,7 +81,7 @@ class Consistency(): """ -class CoreWarnings(): +class CoreWarnings(Enum): """CoreWarnings() Some common warnings which are raised by core functionalities within BuildStream are found in this class. |