Yelp / bravado-core

Other
109 stars 98 forks source link

Ensure hashability of classes with custom equality check #363

Closed macisamuele closed 4 years ago

macisamuele commented 4 years ago

Ensure hashability of classes with custom equality check.

The issue has been noticed because Yelp/swagger-spec-compatibility tests are broken (due to the fact that bravado_core.spec.Spec instances are not hashable).

In #360 equality methods have been added in order to increase testing coverage of deepcopy of instances.

Objects inheriting from object (aka all) have:

Unfortunately, on Python, if you override one __eq__ method then the "default" __hash__ implementation is not is use, and so to make the object hashable again you need to implement __hash__ yourself (what this CR does). (Documentation reference)

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.006%) to 98.508% when pulling 4807fb5c4d611e0ef5c021bc826d098944dd9cee on macisamuele:maci-ensure-hashability into 9c20a251f016870f1f716b7217d3dae4ebbf9c56 on Yelp:master.