From 967f3cda8d88bc631fef224f625b50aa973f3e84 Mon Sep 17 00:00:00 2001 From: Ninjagod1251 <15219900+Ninjagod1251@users.noreply.github.com> Date: Thu, 24 Mar 2022 19:51:32 -0700 Subject: [PATCH] fix: ape plugins list showed core plugins when it was not supposed to (#600) --- .github/workflows/test.yaml | 3 +++ src/ape/utils.py | 6 +----- src/ape_plugins/_cli.py | 2 -- src/ape_plugins/utils.py | 2 +- tests/integration/cli/test_plugins.py | 13 +++++++++++++ 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 tests/integration/cli/test_plugins.py diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1809981a29..3789e1a3fa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -55,6 +55,9 @@ jobs: os: [ubuntu-latest, macos-latest] # eventually add `windows-latest` python-version: [3.7, 3.8, 3.9, "3.10"] + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: - uses: actions/checkout@v2 diff --git a/src/ape/utils.py b/src/ape/utils.py index 11f51f0582..445f75fe86 100644 --- a/src/ape/utils.py +++ b/src/ape/utils.py @@ -390,11 +390,7 @@ class GithubClient: _repo_cache: Dict[str, GithubRepository] = {} def __init__(self): - token = None - self.has_auth = self.TOKEN_KEY in os.environ - if self.has_auth: - token = os.environ[self.TOKEN_KEY] - + token = os.environ[self.TOKEN_KEY] if self.TOKEN_KEY in os.environ else None self._client = Github(login_or_token=token, user_agent=USER_AGENT) @cached_property diff --git a/src/ape_plugins/_cli.py b/src/ape_plugins/_cli.py index 789fe9ed5b..a0f757dafd 100644 --- a/src/ape_plugins/_cli.py +++ b/src/ape_plugins/_cli.py @@ -101,7 +101,6 @@ def _list(cli_ctx, display_all): for name in spaced_names: plugin = ApePlugin(name) - if plugin.is_part_of_core: if not display_all: continue @@ -126,7 +125,6 @@ def _list(cli_ctx, display_all): installed_plugin_lists = [ ls for ls in [installed_org_plugins, installed_third_party_plugins] if ls ] - if installed_plugin_lists: sections["Installed Plugins"] = installed_plugin_lists elif not display_all and available_plugins: diff --git a/src/ape_plugins/utils.py b/src/ape_plugins/utils.py index c21474f3f2..fafe37c678 100644 --- a/src/ape_plugins/utils.py +++ b/src/ape_plugins/utils.py @@ -82,7 +82,7 @@ def can_install(self) -> bool: @property def is_part_of_core(self) -> bool: - return self.module_name in CORE_PLUGINS + return self.module_name.strip() in CORE_PLUGINS @property def is_installed(self) -> bool: diff --git a/tests/integration/cli/test_plugins.py b/tests/integration/cli/test_plugins.py new file mode 100644 index 0000000000..45f027a88f --- /dev/null +++ b/tests/integration/cli/test_plugins.py @@ -0,0 +1,13 @@ +import pytest + +from tests.integration.cli.utils import skip_projects_except + + +@pytest.mark.xfail(strict=False, reason="Github rate limiting issues") +@skip_projects_except(["test"]) # Only run on single project to prevent rate-limiting in CI/CD +def test_list_excludes_core_plugins(ape_cli, runner): + result = runner.invoke(ape_cli, ["plugins", "list"]) + assert result.exit_code == 0, result.output + assert "console" not in result.output, "console is not supposed to be in Installed Plugins" + assert "networks" not in result.output, "networks is not supposed to be in Installed Plugins" + assert "geth" not in result.output, "networks is not supposed to be in Installed Plugins"