def __setitem__(self, key, value):
    if isinstance(value, variables.TestVar):
        try:
            self['_rfm_local_var_space'][key] = value
            value.__set_name__(self, key)
        except KeyError:
            raise ReframeSyntaxError(f'variable {key!r} is already declared') from None
        self._namespace.pop(key, None)
        return
    elif isinstance(value, parameters.TestParam):
        try:
            self['_rfm_local_param_space'][key] = value
        except KeyError:
            raise ReframeSyntaxError(f'parameter {key!r} is already declared in this class') from None
        self._namespace.pop(key, None)
        return
    elif (key in self['_rfm_local_param_space']):
        raise ReframeSyntaxError(f'cannot override parameter {key!r}')
    else:
        self._namespace[key] = value
    if hasattr(value, '_rfm_sanity_fn'):
        try:
            super().__setitem__('_rfm_sanity', value)
        except KeyError:
            raise ReframeSyntaxError('the @sanity_function decorator can only be used once in the class body') from None
    elif hasattr(value, '_rfm_perf_key'):
        try:
            self['_rfm_perf_fns'][key] = value
        except KeyError:
            raise ReframeSyntaxError(f'the performance function {key!r} has already been defined in this class') from None
    if hasattr(value, '_rfm_final'):
        self['_rfm_final_methods'].add(key)
    self['_rfm_hook_registry'].add(value)
def __setitem__(self, key, value):
    if isinstance(value, variables.TestVar):
        try:
            self['_rfm_local_var_space'][key] = value
            value.__set_name__(self, key)
        except KeyError:
            raise ReframeSyntaxError(f'variable {key!r} is already declared') from None
        self._namespace.pop(key, None)
        return
    elif isinstance(value, parameters.TestParam):
        try:
            self['_rfm_local_param_space'][key] = value
        except KeyError:
            raise ReframeSyntaxError(f'parameter {key!r} is already declared in this class') from None
        self._namespace.pop(key, None)
        return
    elif (key in self['_rfm_local_param_space']):
        raise ReframeSyntaxError(f'cannot override parameter {key!r}')
    else:
        self._namespace[key] = value
    if hasattr(value, '_rfm_sanity_fn'):
        try:
            super().__setitem__('_rfm_sanity', value)
        except KeyError:
            raise ReframeSyntaxError('the @sanity_function decorator can only be used once in the class body') from None
    elif hasattr(value, '_rfm_perf_key'):
        try:
            self['_rfm_perf_fns'][key] = value
        except KeyError:
            raise ReframeSyntaxError(f'the performance function {key!r} has already been defined in this class') from None
    if hasattr(value, '_rfm_final'):
        self['_rfm_final_methods'].add(key)
    self['_rfm_hook_registry'].add(value)