Skip to content

Commit

Permalink
[Resolve #1506] Remove unused __eq__ method
Browse files Browse the repository at this point in the history
Way back in 2018, the original team were adding the debug command, and in
that context set about to improve the output in some debug circumstances
during inspection of Sceptre's internal objects.

In response to #570, a custom
`__eq__` method was added in df9fc20.

Based on what can be seen of the original implementation of the custom
`__eq__`, it has not been maintained in a long time, other than changes
to it that appeared to cause issues for the current maintainers.

--

A recent change to improve the output during cyclical dependency errors
has introduced a call to `nx.find_cycle`. This function explicitly
searches for a cycle in the graph. This appears to resolve in code
testing for equality of nodes and thus calls to our custom `__eq__`
function.

The `__eq__` method however has been technically broken ever since
`template_path` was made optional. This then results in `__eq__`
failing. This fails as the code to indicate that `template_path` is
deprecrated is then executed, which will fail if the setting has not
really been defined.

--

This PR proposes to simply remove `__eq__` since it is believed that it
is no longer in use by anything. It has been more than 2 years since
`template_path` was deprecrated and made optional, and the fact of this
bug having never been observed until now is good evidence that it is not
used or needed.
  • Loading branch information
alex-harvey-z3q committed Aug 30, 2024
1 parent 0bfbd21 commit d7c96f5
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions sceptre/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,30 +354,6 @@ def __repr__(self):
def __str__(self):
return self.name

def __eq__(self, stack):
# We should not use any resolvable properties in __eq__, since it is used when adding the
# Stack to a set, which is done very early in plan resolution. Trying to reference resolvers
# before the plan is fully resolved can potentially blow up.
return (
self.name == stack.name
and self.external_name == stack.external_name
and self.project_code == stack.project_code
and self.template_path == stack.template_path
and self.region == stack.region
and self.template_key_prefix == stack.template_key_prefix
and self.required_version == stack.required_version
and self.sceptre_role_session_duration
== stack.sceptre_role_session_duration
and self.profile == stack.profile
and self.dependencies == stack.dependencies
and self.protected == stack.protected
and self.on_failure == stack.on_failure
and self.disable_rollback == stack.disable_rollback
and self.stack_timeout == stack.stack_timeout
and self.ignore == stack.ignore
and self.obsolete == stack.obsolete
)

def __hash__(self):
return hash(str(self))

Expand Down

0 comments on commit d7c96f5

Please sign in to comment.