Skip to content

Commit

Permalink
service.Issue: Remove "mapping type" methods
Browse files Browse the repository at this point in the history
https://docs.python.org/3/library/stdtypes.html#mapping-types-dict

We're no longer relying on implicit `dict()` conversion and are rather
using the `get_taskwarrior_record()` method directly.

I assume the original motivation for this was convenience of use in
third-party applications which used bugwarrior as a library. As far as I
know no such applications are still in use.

In preparation for documenting and stabilizing the base class interfaces
(#791) I'd like to cut them back to a minimum. Maybe the mapping type
could be added back some day if there were demand for it, but it would
then need to conform to a standard of testing a documentation I plan to
implement.
  • Loading branch information
ryneeverett committed Mar 27, 2024
1 parent 09dce95 commit 20972fb
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions bugwarrior/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,49 +290,6 @@ def refine_record(self, record):
record[field] = getattr(self, 'get_default_%s' % field)()
return record

def __iter__(self):
record = self.get_taskwarrior_record()
yield from record.keys()

def keys(self):
return list(self.__iter__())

def iterkeys(self):
return self.__iter__()

def items(self):
record = self.get_taskwarrior_record()
return list(record.items())

def iteritems(self):
record = self.get_taskwarrior_record()
yield from record.items()

def update(self, *args):
raise AttributeError(
"You cannot set attributes on issues."
)

def get(self, attribute, default=None):
try:
return self[attribute]
except KeyError:
return default

def __getitem__(self, attribute):
record = self.get_taskwarrior_record()
return record[attribute]

def __setitem__(self, attribute, value):
raise AttributeError(
"You cannot set attributes on issues."
)

def __delitem__(self, attribute):
raise AttributeError(
"You cannot delete attributes from issues."
)

@property
def record(self):
return self._foreign_record
Expand Down

0 comments on commit 20972fb

Please sign in to comment.