updates a property value if the key already exists Problem: a previously non-existing property can be added to the class instance without error.
(self, key: str, value)
| 26 | yield key, field_def.default |
| 27 | |
| 28 | def update_value(self, key: str, value): |
| 29 | """ |
| 30 | updates a property value if the key already exists |
| 31 | |
| 32 | Problem: a previously non-existing property can be added to the class instance without error. |
| 33 | """ |
| 34 | if hasattr(self, key): |
| 35 | setattr(self, key, value) |
| 36 | else: |
| 37 | error_message = ( |
| 38 | self.__class__.__name__ |
| 39 | + ".update_value() to be updated property " |
| 40 | + str(key) |
| 41 | + " does not exist" |
| 42 | ) |
| 43 | logging.error(error_message) |
| 44 | raise ValueError(error_message) |
| 45 | |
| 46 | def update_values(self, d): |
| 47 | """ |
no outgoing calls