Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 6fbbd76

Browse files
committed
add __delattr__ method to models
1 parent e90ba23 commit 6fbbd76

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
1.2 (unreleased)
2+
----------------
3+
4+
- you can now remove model attributes with `del`
5+
6+
17
1.1
28
---
39

atomx/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ def __setattr__(self, key, value):
6464
self._attributes[key] = value
6565
self._dirty.add(key)
6666

67+
def __delattr__(self, item):
68+
if item in self._dirty:
69+
self._dirty.remove[item]
70+
else:
71+
self._attributes[item] = None
72+
self._dirty.add(item)
73+
6774
def __dir__(self):
6875
"""Manually add dynamic attributes for autocomplete"""
6976
return dir(type(self)) + list(self.__dict__.keys()) + list(self._attributes.keys())

atomx/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VERSION = '1.1'
1+
VERSION = '1.2b'
22
API_VERSION = 'v1'

0 commit comments

Comments
 (0)