| Total Complexity | 5 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from overpy import Node # type: ignore |
||
| 2 | |||
| 3 | |||
| 4 | # future: embed this into overpy.Node |
||
| 5 | class HashableNodeSnapshot(Node): |
||
| 6 | def __init__(self, node: Node): |
||
| 7 | super().__init__( |
||
| 8 | node_id=node.id, |
||
| 9 | lat=node.lat, |
||
| 10 | lon=node.lon, |
||
| 11 | attributes=node.attributes, |
||
| 12 | result=node._result, |
||
| 13 | tags=node.tags, |
||
| 14 | ) |
||
| 15 | |||
| 16 | def __hash__(self) -> int: |
||
| 17 | return hash((self.id, self.lat, self.lon, frozenset(self.tags.items()))) |
||
| 18 | |||
| 19 | def __eq__(self, other: object) -> bool: |
||
| 20 | if isinstance(other, HashableNodeSnapshot) or isinstance(other, Node): |
||
| 21 | return (self.id, self.lat, self.lon, self.tags.items()) == ( |
||
| 22 | other.id, |
||
| 23 | other.lat, |
||
| 24 | other.lon, |
||
| 25 | other.tags.items(), |
||
| 26 | ) |
||
| 27 | |||
| 28 | return NotImplemented |
||
| 29 |