util/toml: disable unspecified-encoding check
This commit is contained in:
parent
30fcf37c03
commit
b496732a02
1 changed files with 7 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ from types import ModuleType
|
|||
from typing import Optional
|
||||
|
||||
# Different modules require different file mode (text vs binary)
|
||||
toml_modules = {
|
||||
_toml_modules = {
|
||||
"tomllib": {"mode": "rb"}, # stdlib since 3.11 (read-only)
|
||||
"tomli": {"mode": "rb"}, # EL9+
|
||||
"toml": {"mode": "r", "encoding": "utf-8"}, # older unmaintained lib, needed for backwards compatibility
|
||||
|
|
@ -18,7 +18,7 @@ toml_modules = {
|
|||
|
||||
_toml: Optional[ModuleType] = None
|
||||
_rargs: dict = {}
|
||||
for module, args in toml_modules.items():
|
||||
for module, args in _toml_modules.items():
|
||||
try:
|
||||
_toml = importlib.import_module(module)
|
||||
_rargs = args
|
||||
|
|
@ -26,10 +26,10 @@ for module, args in toml_modules.items():
|
|||
except ModuleNotFoundError:
|
||||
pass
|
||||
else:
|
||||
raise ModuleNotFoundError("No toml module found: " + ", ".join(toml_modules))
|
||||
raise ModuleNotFoundError("No toml module found: " + ", ".join(_toml_modules))
|
||||
|
||||
# Different modules require different file mode (text vs binary)
|
||||
tomlw_modules = {
|
||||
_tomlw_modules = {
|
||||
"tomli_w": {"mode": "wb"}, # EL9+
|
||||
"toml": {"mode": "w", "encoding": "utf-8"}, # older unmaintained lib, needed for backwards compatibility
|
||||
"pytoml": {"mode": "w", "encoding": "utf-8"}, # deprecated, needed for backwards compatibility (EL8 manifests)
|
||||
|
|
@ -38,7 +38,7 @@ tomlw_modules = {
|
|||
|
||||
_tomlw: Optional[ModuleType] = None
|
||||
_wargs: dict = {}
|
||||
for module, args in tomlw_modules.items():
|
||||
for module, args in _tomlw_modules.items():
|
||||
try:
|
||||
_tomlw = importlib.import_module(module)
|
||||
_wargs = args
|
||||
|
|
@ -52,7 +52,7 @@ def load_from_file(path):
|
|||
if _toml is None:
|
||||
raise RuntimeError("no toml module available")
|
||||
|
||||
with open(path, **_rargs) as tomlfile:
|
||||
with open(path, **_rargs) as tomlfile: # pylint: disable=unspecified-encoding
|
||||
return _toml.load(tomlfile)
|
||||
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ def dump_to_file(data, path, header=""):
|
|||
if _tomlw is None:
|
||||
raise RuntimeError("no toml module available with write support")
|
||||
|
||||
with open(path, **_wargs) as tomlfile:
|
||||
with open(path, **_wargs) as tomlfile: # pylint: disable=unspecified-encoding
|
||||
if header:
|
||||
_write_comment(tomlfile, header)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue