troposphere: TypeError: unhashable type: 'Parameter'

Hello,

This might be something that only affects me, but I have been relying for 3 years now and built my application to rely on the Parameters as keys to dict. In the 4.5.0, I am getting the error

TypeError: unhashable type: 'Parameter' and basically now, the entire thing is broken. Seems to me the change is with, but I am not entirely sure.

    def __hash__(self) -> int:
        return hash(self.to_json(indent=0))

What to do now?

EDIT:

Here is an example among many of how I am able to use it in dict: https://github.com/compose-x/ecs_composex/blob/main/ecs_composex/dynamodb/dynamodb_stack.py#L38

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

@ITProKyle thank you for the thorough writeup and alternatives. I agree there isn’t a perfect solution. I’m leaning towards your last suggestion as the least disruptive. This could also be applied to the class Parameter instead of class BaseAWSObject to work around this issue. Not sure if that would be better or worse so open to thoughts from you and @JohnPreston.

class BaseAWSObject:

    def __hash__(self) -> int:
        return hash(json.dumps({"title": self.title, **self.to_dict()}, indent=0))