code: def modify_symbol(sym: ast.Symbol, scope: ast.InstanceClass) -> None:
      
  
      # We assume that we do not screw up the order of applying modifications
      # when "moving up" with the scope.
      apply_args = [x for x in sym.class_modification.arguments
                    if x.scope is None or x.scope.full_reference().to_tuple() == scope.full_reference().to_tuple()]
      skip_args = [x for x in sym.class_modification.arguments
                   if x.scope is not None and x.scope.full_reference().to_tuple() != scope.full_reference().to_tuple()]
  
      for class_mod_argument in apply_args:
          argument = class_mod_argument.value
  
          assert isinstance(argument, ast.ElementModification), \
              "Found redeclaration modification which should already have been handled."
  
          # TODO: Strip all non-symbol stuff.
          if argument.component.name not in ast.Symbol.ATTRIBUTES:
              raise Exception("Trying to set unknown symbol property {}".format(argument.component.name))
  
          setattr(sym, argument.component.name, argument.modifications[0])
  
      sym.class_modification.arguments = skip_args
docs: Apply a modification to a symbol if the scope matches (or is None)
      :param sym: symbol to apply modifications for
      :param scope: scope of modification