From ee932a40bc513ac51a31a3054ce6595bfb37d32f Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 15 Feb 2024 09:28:07 +0000 Subject: [PATCH] cfg.py: restore importlib_resources import (pylint bug workaround) --- .github/workflows/pylint.yaml | 2 +- mmgen/cfg.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml index 685ded0a..69c91cc4 100644 --- a/.github/workflows/pylint.yaml +++ b/.github/workflows/pylint.yaml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - python-version: ["3.10","3.11"] + python-version: ["3.9","3.10","3.11"] steps: - uses: actions/checkout@v4 diff --git a/mmgen/cfg.py b/mmgen/cfg.py index dc5487dd..7dccfd7f 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -75,7 +75,12 @@ class GlobalConstants(Lockable): # Resource Access without the performance overhead of that package. # https://importlib-resources.readthedocs.io/en/latest/migration.html # https://setuptools.readthedocs.io/en/latest/pkg_resources.html - from importlib.resources import files + + # TODO: remove try..except (workaround for Python 3.9 pylint bug) + try: + from importlib.resources import files # Python 3.9 and above + except ImportError: + from importlib_resources import files return files(package).joinpath('data',filename).read_text() @property