Skip to content

Commit

Permalink
Fix Python 3.9 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Jul 30, 2023
1 parent b34a7be commit 3695efe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions skytemple/core/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import sys
import logging
from typing import TYPE_CHECKING, Type
from typing import TYPE_CHECKING, Type, Iterable

from typing import Dict

Expand All @@ -41,12 +41,18 @@ class Modules:
@classmethod
def load(cls):
# Look up package entrypoints for modules
cls._modules = {}
try:
modules: Iterable[importlib_metadata.EntryPoint]
if sys.version_info < (3, 10):
modules = importlib_metadata.entry_points()[MODULE_ENTRYPOINT_KEY]
else:
modules = importlib_metadata.entry_points().select(group=MODULE_ENTRYPOINT_KEY)
cls._modules = {
entry_point.name:
entry_point.load() for entry_point in importlib_metadata.entry_points().select(group=MODULE_ENTRYPOINT_KEY)
entry_point.load() for entry_point in modules
}
except BaseException as ex:
except Exception as ex:
logger.warning("Failed loading modules.", exc_info=ex)

if len(cls._modules) < 1:
Expand Down

0 comments on commit 3695efe

Please sign in to comment.