From 6c4d75474fa8dfe58c4bc8c32e27eb2d9f10fa1a Mon Sep 17 00:00:00 2001 From: ZM25XC <78628186+ZM25XC@users.noreply.github.com> Date: Sun, 9 Jul 2023 13:51:13 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20Fix:=20=E4=BD=BF=E7=94=A8=20nb=20?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=89=BE=E4=B8=8D=E5=88=B0=20`pyproject.toml?= =?UTF-8?q?`=20(#91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> --- nb_cli/cli/customize.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nb_cli/cli/customize.py b/nb_cli/cli/customize.py index 6506c21..cd4fdc0 100644 --- a/nb_cli/cli/customize.py +++ b/nb_cli/cli/customize.py @@ -5,6 +5,7 @@ import click from nb_cli import _, cache +from nb_cli.exceptions import ProjectNotFoundError from nb_cli.handlers import run_script, list_scripts from .utils import run_async @@ -118,7 +119,12 @@ def _build_script_command(self, script_name: str) -> click.Command: @run_async # type: ignore @cache(ttl=None) async def _load_scripts(self, ctx: click.Context) -> List[click.Command]: - scripts = await list_scripts() + try: + scripts = await list_scripts() + except ProjectNotFoundError: + # not in a project + return [] + # check duplicate elements = Counter(scripts).most_common() if elements and elements[0][1] > 1: