Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement TruncableSteps.__setitem__ for slice, and int #162

Closed
alexbrillant opened this issue Oct 30, 2019 · 0 comments
Closed

Implement TruncableSteps.__setitem__ for slice, and int #162

alexbrillant opened this issue Oct 30, 2019 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@alexbrillant
Copy link
Contributor

    def __setitem__(self, key: Union[slice, int, str], new_step: BaseStep):
        """
        Set one step with a key, and a value.

        :param key: slice, index, or step name
        :type key: Union[slice, int, str]
        :param new_step: step
        :type new_step: BaseStep
        """
        if isinstance(key, str):
            index = 0
            for step_index, (current_step_name, step) in enumerate(self.steps_as_tuple):
                if current_step_name == key:
                    index = step_index

            new_step.set_name(key)
            self.steps[index] = new_step
            self.steps_as_tuple[index] = (key, new_step)
        else:
            # TODO !! issue 
            raise ValueError('type {0} not supported yet in TruncableSteps.__setitem__, please implement it if you need it'.format(type(key)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant