
class StageArgs(object):
    def __init__(self, stage, args):
        self.stage = stage
        self.args = args

    def __getattr__(self, key):
        real_key = '{}{}'.format(key, self.stage.postfix)
        if not hasattr(self.args, real_key):
            return None
        return getattr(self.args, real_key)


class Stage(object):
    def __init__(self, identifier, postfix=""):
        self.identifier = identifier
        self.postfix = postfix


STAGE_1 = Stage(1, "")
STAGE_2 = Stage(2, "_stage2")


class StageArgs(object):
    def __init__(self, stage, args):
        self.stage = stage
        self.args = args
        assert(not isinstance(self.args, StageArgs))

    def __getattr__(self, key):
        real_key = '{}{}'.format(key, self.stage.postfix)
        if not hasattr(self.args, real_key):
            return None
        return getattr(self.args, real_key)


class Stage(object):
    def __init__(self, identifier, postfix=""):
        self.identifier = identifier
        self.postfix = postfix


STAGE_1 = Stage(1, "")
STAGE_2 = Stage(2, "_stage2")

Make sure that StageArgs are never passed a StageArgs as their args.
[build-script] Make sure that StageArgs are never passed a StageArgs as their args.

No good reason to do this and simplifies the state space.

  
  class StageArgs(object):
      def __init__(self, stage, args):
          self.stage = stage
          self.args = args
+         assert(not isinstance(self.args, StageArgs))
  
      def __getattr__(self, key):
          real_key = '{}{}'.format(key, self.stage.postfix)
          if not hasattr(self.args, real_key):
              return None
          return getattr(self.args, real_key)
  
  
  class Stage(object):
      def __init__(self, identifier, postfix=""):
          self.identifier = identifier
          self.postfix = postfix
  
  
  STAGE_1 = Stage(1, "")
  STAGE_2 = Stage(2, "_stage2")
  
Make sure that StageArgs are never passed a StageArgs as their args.
## Code Before:

class StageArgs(object):
    def __init__(self, stage, args):
        self.stage = stage
        self.args = args

    def __getattr__(self, key):
        real_key = '{}{}'.format(key, self.stage.postfix)
        if not hasattr(self.args, real_key):
            return None
        return getattr(self.args, real_key)


class Stage(object):
    def __init__(self, identifier, postfix=""):
        self.identifier = identifier
        self.postfix = postfix


STAGE_1 = Stage(1, "")
STAGE_2 = Stage(2, "_stage2")

## Instruction:
Make sure that StageArgs are never passed a StageArgs as their args.
## Code After:

class StageArgs(object):
    def __init__(self, stage, args):
        self.stage = stage
        self.args = args
        assert(not isinstance(self.args, StageArgs))

    def __getattr__(self, key):
        real_key = '{}{}'.format(key, self.stage.postfix)
        if not hasattr(self.args, real_key):
            return None
        return getattr(self.args, real_key)


class Stage(object):
    def __init__(self, identifier, postfix=""):
        self.identifier = identifier
        self.postfix = postfix


STAGE_1 = Stage(1, "")
STAGE_2 = Stage(2, "_stage2")
