Skip to content

Commit 464b675

Browse files
committed
Add API changelog
Fix import of get_service after rebase
1 parent 66640e1 commit 464b675

5 files changed

Lines changed: 47 additions & 29 deletions

File tree

bugwarrior/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
StrippedTrailingSlashUrl, # noqa: F401
1616
TaskrcPath, # noqa: F401
1717
UnsupportedOption, # noqa: F401
18+
get_service, # noqa:F401
1819
)
1920
from .secrets import get_keyring # noqa: F401
20-
from .validation import get_service # noqa:F401
2121

2222
# NOTE: __all__ determines the stable, public API.
2323
__all__ = [BugwarriorData.__name__, MainSectionConfig.__name__, ServiceConfig.__name__]

bugwarrior/config/schema.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from functools import cache
2+
from importlib.metadata import entry_points
13
import logging
24
import os
35
from pathlib import Path
46
import re
57
import typing
6-
from typing import Annotated, Any, Literal
8+
from typing import TYPE_CHECKING, Annotated, Any, Literal
79

810
import pydantic
911
from pydantic import (
@@ -23,6 +25,9 @@
2325

2426
from .data import BugwarriorData, get_data_path
2527

28+
if TYPE_CHECKING:
29+
from bugwarrior.services import Service
30+
2631
log = logging.getLogger(__name__)
2732

2833
Priority = Literal['', 'L', 'M', 'H']
@@ -215,8 +220,6 @@ class ServiceConfig(_ServiceConfig):
215220

216221
@property
217222
def keyring_service(self) -> str:
218-
# FIXME change this import and move it outside method after rebase
219-
from bugwarrior.collect import get_service
220223

221224
service = get_service(self.service)
222225
if service.API_VERSION < 2:
@@ -291,3 +294,23 @@ def deprecate_project_name(cls, value: str) -> str:
291294
if value != '':
292295
log.warning('project_name is deprecated in favor of project_template')
293296
return value
297+
298+
299+
@cache
300+
def get_service(service_name: str) -> type["Service"]:
301+
try:
302+
(service,) = entry_points(group='bugwarrior.service', name=service_name)
303+
except ValueError as e:
304+
if service_name in [
305+
'activecollab',
306+
'activecollab2',
307+
'megaplan',
308+
'teamlab',
309+
'versionone',
310+
]:
311+
log.warning(f"The {service_name} service has been removed.")
312+
raise ValueError(
313+
f"Configured service '{service_name}' not found. "
314+
"Is it installed? Or misspelled?"
315+
) from e
316+
return service.load()

bugwarrior/config/validation.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
1-
from functools import cache
2-
from importlib.metadata import entry_points
31
import logging
42
import sys
53
from typing import TYPE_CHECKING, Annotated, Any, NoReturn, Union
64

75
from pydantic import Field, TypeAdapter, ValidationError
86
from pydantic_core import ErrorDetails
97

10-
from .schema import BaseConfig, Hooks, MainSectionConfig, Notifications, ServiceConfig
8+
from .schema import (
9+
BaseConfig,
10+
Hooks,
11+
MainSectionConfig,
12+
Notifications,
13+
ServiceConfig,
14+
get_service,
15+
)
1116

1217
if TYPE_CHECKING:
1318
ServiceConfigType = ServiceConfig
14-
from bugwarrior.services import Service
15-
16-
17-
@cache
18-
def get_service(service_name: str) -> type["Service"]:
19-
try:
20-
(service,) = entry_points(group='bugwarrior.service', name=service_name)
21-
except ValueError as e:
22-
if service_name in [
23-
'activecollab',
24-
'activecollab2',
25-
'megaplan',
26-
'teamlab',
27-
'versionone',
28-
]:
29-
log.warning(f"The {service_name} service has been removed.")
30-
raise ValueError(
31-
f"Configured service '{service_name}' not found. "
32-
"Is it installed? Or misspelled?"
33-
) from e
34-
return service.load()
3519

3620

3721
log = logging.getLogger(__name__)

bugwarrior/docs/other-services/api.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,14 @@ warning, release notes, or semantic version bumping.
1515
:exclude-members: __init__,compute_templates,model_config
1616
:imported-members:
1717
:member-order: bysource
18+
19+
Changelog
20+
---------
21+
22+
v2.0
23+
~~~~
24+
25+
- Removed ``Service.get_keyring_service(config)``. Service configurations should
26+
define ``KEYRING_SERVICE`` instead.
27+
- Added ``ServiceConfig.KEYRING_SERVICE`` as a format string for generating the
28+
keyring service identifier from service configuration fields.

tests/test_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def get_keyring_service(config):
111111

112112
service_config = ServiceConfig(service='legacy', target='legacy-target')
113113
with unittest.mock.patch(
114-
'bugwarrior.collect.get_service', lambda _: LegacyService
114+
'bugwarrior.config.schema.get_service', lambda _: LegacyService
115115
):
116116
self.assertEqual(service_config.keyring_service, 'legacy://legacy-target')
117117

0 commit comments

Comments
 (0)