From dd0667ea8f74a3e762dd981215667a73a18e6331 Mon Sep 17 00:00:00 2001 From: nvbn Date: Sun, 6 Sep 2015 13:37:48 +0300 Subject: [PATCH] #356 Ignore `thefuck` entry points --- tests/test_utils.py | 2 +- thefuck/utils.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 99c22464..b51ec394 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -53,7 +53,7 @@ def get_aliases(mocker): @pytest.mark.usefixtures('no_memoize', 'get_aliases') -def test_get_all_callables(): +def test_get_all_executables(): all_callables = get_all_executables() assert 'vim' in all_callables assert 'fsck' in all_callables diff --git a/thefuck/utils.py b/thefuck/utils.py index 2736e853..57fe2f50 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -10,6 +10,7 @@ import pickle import re from pathlib import Path +import pkg_resources import six @@ -94,11 +95,17 @@ def get_all_executables(): return fallback tf_alias = thefuck_alias() - return [exe.name + tf_entry_points = pkg_resources.require('thefuck')[0]\ + .get_entry_map()\ + .get('console_scripts', {})\ + .keys() + bins = [exe.name for path in os.environ.get('PATH', '').split(':') for exe in _safe(lambda: list(Path(path).iterdir()), []) - if not _safe(exe.is_dir, True)] + [ - alias for alias in get_aliases() if alias != tf_alias] + if not _safe(exe.is_dir, True) + and exe.name not in tf_entry_points] + aliases = [alias for alias in get_aliases() if alias != tf_alias] + return bins + aliases def replace_argument(script, from_, to):