Skip to content

Commit d127e53

Browse files
msglmShadow53
authored andcommitted
Update to modern standards
1 parent 8a6180a commit d127e53

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

bugwarrior/services/gitea.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"""Bugwarrior service support class for Gitea
44
55
Available classes:
6-
- GiteaClient(ServiceClient): Constructs Gitea API strings
6+
- GiteaClient(Service): Constructs Gitea API strings
77
- GiteaIssue(Issue): TaskWarrior Interface
8-
- GiteaService(IssueService): Engine for firing off requests
8+
- GiteaService(Issue): Engine for firing off requests
99
1010
Todo:
1111
* Add token support
@@ -25,7 +25,7 @@
2525
from jinja2 import Template
2626

2727
from bugwarrior import config
28-
from bugwarrior.services import IssueService, Issue, ServiceClient
28+
from bugwarrior.services import Issue, Service, Client
2929

3030
log = logging.getLogger(__name__) # pylint: disable-msg=C0103
3131

@@ -62,7 +62,7 @@ def get(self, key, default=None, to_type=None):
6262
return default
6363

6464

65-
class GiteaClient(ServiceClient):
65+
class GiteaClient(Client):
6666
"""Builds Gitea API strings
6767
Args:
6868
host (str): remote gitea server
@@ -263,8 +263,11 @@ class GiteaIssue(Issue):
263263
@staticmethod
264264
def _normalize_label_to_tag(label):
265265
return re.sub(r'[^a-zA-Z0-9]', '_', label)
266+
def get_tags(self):
267+
labels = [label['name'] for label in self.record.get('labels', [])]
268+
return self.get_tags_from_labels(labels)
266269

267-
def to_taskwarrior(self):
270+
def to_taskwarrior(self) -> dict:
268271
milestone = self.record['milestone']
269272
if milestone:
270273
milestone = milestone['title']
@@ -302,31 +305,18 @@ def to_taskwarrior(self):
302305
self.NAMESPACE: self.extra['namespace'],
303306
self.STATE: self.record.get('state', '')
304307
}
305-
def get_tags(self):
306-
labels = [label['name'] for label in self.record.get('labels', [])]
307-
return self.get_tags_from_labels(labels)
308-
309-
def get_default_description(self):
310-
log.info('In get_default_description')
311-
return self.build_default_description(
312-
title=self.record['title'],
313-
url=self.get_processed_url(self.record['url']),
314-
number=self.record['number'],
315-
cls=self.extra['type'],
316-
)
317-
318308

319309
def get_default_description(self):
320310
log.info('In get_default_description')
321311
return self.build_default_description(
322312
title=self.record['title'],
323-
url=self.get_processed_url(self.record['url']),
313+
url=self.record['url'],
324314
number=self.record['number'],
325315
cls=self.extra['type'],
326316
)
327317

328318

329-
class GiteaService(IssueService):
319+
class GiteaService(Service):
330320
ISSUE_CLASS = GiteaIssue
331321
CONFIG_SCHEMA = GiteaConfig
332322
CONFIG_PREFIX = 'gitea'
@@ -455,7 +445,7 @@ def annotations(self, tag, issue, issue_obj):
455445
) for c in comments)
456446
annotations_result = self.build_annotations(
457447
annotations,
458-
issue_obj.get_processed_url(url))
448+
url)
459449
log.info('annotations: {}'.format(annotations_result))
460450
return annotations_result
461451

@@ -573,6 +563,9 @@ def issues(self):
573563
'annotations': [issue['body']],
574564
'namespace': self.username,
575565
}
576-
issue_obj.update_extra(extra)
566+
issue_obj.extra.update(extra)
577567
yield issue_obj
578568

569+
570+
571+

0 commit comments

Comments
 (0)