Skip to content

Commit a3851a1

Browse files
author
ocarmi
committed
Use importlib_metadata for entry_points
1 parent 6e072ce commit a3851a1

File tree

3 files changed

+801
-799
lines changed

3 files changed

+801
-799
lines changed

notifiers/core.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import importlib.util
55
import logging
66
from abc import ABC, abstractmethod
7-
from importlib.metadata import entry_points
87

98
import jsonschema
109
import requests
10+
from importlib_metadata import entry_points
1111
from jsonschema.exceptions import best_match
1212

1313
from .exceptions import BadArguments, NoSuchNotifierError, NotificationError, SchemaError
@@ -397,12 +397,7 @@ def get_providers_from_entry_points(group_name: str = "notifiers") -> dict:
397397
>>> get_providers_from_entry_points("notifiers")
398398
{"plugin1": "package.module:PluginClass", "plugin2": "package2.module:OtherPluginClass"}
399399
"""
400-
result: dict = {}
401-
points = entry_points()
402-
for item in points.get(group_name, []):
403-
if item.group == group_name:
404-
result[item.name] = load_provider_from_points(item.value)
405-
return result
400+
return {point.name: load_provider_from_points(point.value) for point in entry_points(group=group_name)}
406401

407402

408403
def get_all_providers() -> dict:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ classifiers = [
2828
"License :: OSI Approved :: MIT License",
2929
"Operating System :: OS Independent",
3030
"Programming Language :: Python",
31-
"Programming Language :: Python :: 3.8",
3231
"Programming Language :: Python :: 3.9",
3332
"Programming Language :: Python :: 3.10",
3433
"Programming Language :: Python :: 3.11",
@@ -39,6 +38,7 @@ classifiers = [
3938
]
4039
dependencies = [
4140
"click>=8.0.3",
41+
"importlib-metadata>=3.6",
4242
"jsonschema>=4.4.0",
4343
"requests>=2.27.1,<3",
4444
]

0 commit comments

Comments
 (0)