diff --git a/thefuck/entrypoints/main.py b/thefuck/entrypoints/main.py index 865b9ca..856a3d2 100644 --- a/thefuck/entrypoints/main.py +++ b/thefuck/entrypoints/main.py @@ -7,7 +7,7 @@ import os # noqa: E402 import sys # noqa: E402 from .. import logs # noqa: E402 from ..argument_parser import Parser # noqa: E402 -from ..utils import get_installation_info # noqa: E402 +from ..utils import get_installation_version # noqa: E402 from ..shells import shell # noqa: E402 from .alias import print_alias # noqa: E402 from .fix_command import fix_command # noqa: E402 @@ -20,7 +20,7 @@ def main(): if known_args.help: parser.print_help() elif known_args.version: - logs.version(get_installation_info().version, + logs.version(get_installation_version(), sys.version.split()[0], shell.info()) # It's important to check if an alias is being requested before checking if # `TF_HISTORY` is in `os.environ`, otherwise it might mess with subshells. diff --git a/thefuck/utils.py b/thefuck/utils.py index 1df1134..38d8c11 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -294,10 +294,15 @@ def cache(*depends_on): cache.disabled = False -def get_installation_info(): - import pkg_resources +def get_installation_version(): + try: + from importlib.metadata import version - return pkg_resources.require('thefuck')[0] + return version('thefuck') + except ImportError: + import pkg_resources + + return pkg_resources.require('thefuck')[0].version def get_alias():