File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import typing
1111
1212
13+ try :
14+ # do we have Python 3.12+
15+ from importlib .metadata import EntryPoints # type: ignore # noqa: F401
16+
17+ HAS_IMPORTLIB_ENTRYPOINTS = True
18+ except ImportError :
19+ HAS_IMPORTLIB_ENTRYPOINTS = False
20+
21+
1322@dataclass
1423class Setting :
1524 name : str
@@ -165,9 +174,14 @@ def domain(self, name: str) -> typing.Optional[Domain]:
165174
166175@functools .lru_cache (maxsize = 4096 )
167176def load_topics () -> typing .List [Topic ]:
168- eps = entry_points ()
169- ep_topics = [ep for ep in eps if ep .group == "mxmake.topics" ]
170- return [ep .load () for ep in ep_topics ]
177+ if HAS_IMPORTLIB_ENTRYPOINTS :
178+ topics_eps = entry_points (group = "mxmake.topics" ) # type: ignore
179+ else :
180+ eps = entry_points ()
181+ if "mxmake.topics" not in eps :
182+ return []
183+ topics_eps = eps ["mxmake.topics" ]
184+ return [ep .load () for ep in topics_eps ] # type: ignore
171185
172186
173187def get_topic (name : str ) -> Topic :
You can’t perform that action at this time.
0 commit comments