Skip to content

Commit

Permalink
Add conditional import to fix importlib not available in python 3.7
Browse files Browse the repository at this point in the history
Signed-off-by: noklam <nok.lam.chan@quantumblack.com>
  • Loading branch information
noklam committed May 18, 2022
1 parent a0765e6 commit 3c12bcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kedro/framework/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from typing import Any, Dict, Iterable, List, Mapping, Sequence, Set, Tuple, Union

import click
import importlib_metadata

from kedro.utils import importlib_metadata

CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
MAX_SUGGESTIONS = 3
Expand Down
9 changes: 9 additions & 0 deletions kedro/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
of kedro package.
"""
import importlib
import sys
from typing import Any

# backward compatiblity
if sys.version_info >= (3, 8):
from importlib import ( # noqa: F401 # pylint: disable=unused-import,
metadata as importlib_metadata,
)
else:
import importlib_metadata # noqa: F401 # pylint: disable=unused-import


def load_obj(obj_path: str, default_obj_path: str = "") -> Any:
"""Extract an object from a given path.
Expand Down

0 comments on commit 3c12bcc

Please sign in to comment.