Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pkg-resources dependency #169

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion knowit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
__short_version__ = '.'.join(__version__.split('.')[:2])
__author__ = metadata.metadata(__package__)['author']
__license__ = metadata.metadata(__package__)['license']
__url__ = metadata.metadata(__package__)['home_page']

del metadata

Expand Down
9 changes: 7 additions & 2 deletions knowit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
import typing
from logging import NullHandler, getLogger

from pkg_resources import resource_stream
import yaml

try:
from importlib.resources import files
except ImportError:
from importlib_resources import files # type: ignore[assignment,no-redef,import-not-found]

from knowit.serializer import get_yaml_loader

logger = getLogger(__name__)
Expand All @@ -28,7 +32,8 @@ class Config:
def build(cls, path: typing.Optional[typing.Union[str, os.PathLike]] = None) -> 'Config':
"""Build config instance."""
loader = get_yaml_loader()
with resource_stream('knowit', 'defaults.yml') as stream:
config_file = files(__package__).joinpath('defaults.yml')
with config_file.open('rb') as stream:
cfgs = [yaml.load(stream, Loader=loader)]

if path:
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def assert_expected(expected, actual, options=None):
for (key, expected, actual) in different:
print('{0}: Expected {1} got {2}'.format(key, expected, actual), file=sys.stderr)

if different and options and options['debug_data']:
if different and options and options.get('debug_data'):
print(f'Version: {version}')
print(options['debug_data']())

Expand Down
Loading