Browse Source

cfg.py: restore importlib_resources import (pylint bug workaround)

The MMGen Project 8 months ago
parent
commit
ee932a40bc
2 changed files with 7 additions and 2 deletions
  1. 1 1
      .github/workflows/pylint.yaml
  2. 6 1
      mmgen/cfg.py

+ 1 - 1
.github/workflows/pylint.yaml

@@ -17,7 +17,7 @@ jobs:
 
 
     strategy:
     strategy:
       matrix:
       matrix:
-        python-version: ["3.10","3.11"]
+        python-version: ["3.9","3.10","3.11"]
 
 
     steps:
     steps:
     - uses: actions/checkout@v4
     - uses: actions/checkout@v4

+ 6 - 1
mmgen/cfg.py

@@ -75,7 +75,12 @@ class GlobalConstants(Lockable):
 		#        Resource Access without the performance overhead of that package.
 		#        Resource Access without the performance overhead of that package.
 		#    https://importlib-resources.readthedocs.io/en/latest/migration.html
 		#    https://importlib-resources.readthedocs.io/en/latest/migration.html
 		#    https://setuptools.readthedocs.io/en/latest/pkg_resources.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()
 		return files(package).joinpath('data',filename).read_text()
 
 
 	@property
 	@property