Skip to content

Commit

Permalink
Ignore some importlib-resources type errors
Browse files Browse the repository at this point in the history
During static type checking, always install the old version of
importlib-resources that works with Python 3.6 because the contents()
and path() functions were removed in the latest version but the
alternative to them only works with newer Python versions.

Ignore types for files().joinpath() because this old version does not
provide type definitions for its return type.
  • Loading branch information
affenull2345 committed Jan 8, 2024
1 parent b591ad6 commit 3778098
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tests_require =

lint_requires =
importlib-metadata>=3.10.1
importlib-resources>=5.4.0
importlib-resources==5.4.0
pre-commit>=2.0.1
black>=22.1.0
pyright>=0.0.13
Expand Down
4 changes: 2 additions & 2 deletions src/cobbler_tftp/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ def load_config_file(self, config_path: Union[Path, None]) -> SettingsDict:
config_file_content = (
files("cobbler_tftp.settings.data")
.joinpath("settings.yml")
.read_text(encoding="UTF-8")
.read_text(encoding="UTF-8") # type: ignore
)
self._settings_dict = yaml.safe_load(config_file_content)
except yaml.YAMLError:
print(f"Error: No valid configuration file found at {config_path}!")
elif config_path and Path.exists(config_path):
try:
config_file_content = (
files(config_import_path).joinpath(config_file).read_text("utf-8")
files(config_import_path).joinpath(config_file).read_text("utf-8") # type: ignore
)
self._settings_dict = yaml.safe_load(config_file_content)
except yaml.YAMLError:
Expand Down

0 comments on commit 3778098

Please sign in to comment.