Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update entry points access #1073

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions bugwarrior/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import multiprocessing
import time

from importlib_metadata import entry_points
from jinja2 import Template
from pkg_resources import iter_entry_points

from taskw.task import Task

Expand All @@ -15,14 +15,13 @@
SERVICE_FINISHED_ERROR = 1


def get_service(service_name):
epoint = iter_entry_points(group='bugwarrior.service', name=service_name)
def get_service(service_name: str):
try:
epoint = next(epoint)
except StopIteration:
return None

return epoint.load()
(service,) = entry_points(group='bugwarrior.service', name=service_name)
except ValueError as e:
raise ValueError(f"Configured service '{service_name}' not found. "
"Is it installed? Or misspelled?") from e
return service.load()


def _aggregate_issues(conf, main_section, target, queue):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import glob
import os.path
import pathlib
import pkg_resources
import re
import socket
import subprocess
import tempfile
import unittest

from importlib_metadata import entry_points

DOCS_PATH = pathlib.Path(__file__).parent / '../bugwarrior/docs'

try:
Expand Down Expand Up @@ -69,7 +70,7 @@ def test_manpage_build_without_warning(self):
def test_registered_services_are_documented(self):
registered_services = set(
e.name for e in
pkg_resources.iter_entry_points(group='bugwarrior.service'))
entry_points(group='bugwarrior.service'))

documented_services = set()
services_paths = os.listdir(DOCS_PATH / 'services')
Expand Down
Loading