You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:23:36 UTC

[buildstream] branch chandan/enums created (now fa6d985)

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a change to branch chandan/enums
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at fa6d985  types.py: Derive enumerations from standard library classes

This branch includes the following new commits:

     new fa6d985  types.py: Derive enumerations from standard library classes

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/01: types.py: Derive enumerations from standard library classes

Posted by no...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch chandan/enums
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit fa6d9856c86e1fe72af02f4ef32267b66be49c75
Author: Chandan Singh <ch...@chandansingh.net>
AuthorDate: Tue Jul 16 22:08:28 2019 +0100

    types.py: Derive enumerations from standard library classes
    
    `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.
---
 src/buildstream/types.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/buildstream/types.py b/src/buildstream/types.py
index 6f6262e..d186c4f 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.