From a32f2f507d1a2fb23d8f470e4f5a053584cda634 Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:06:20 +0000 Subject: [PATCH] :bug: exclude dir startswith `._` --- nb_cli/cli/commands/adapter.py | 7 ++++++- nb_cli/cli/commands/plugin.py | 7 ++++++- nb_cli/cli/customize.py | 1 - nb_cli/handlers/reloader.py | 3 +-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nb_cli/cli/commands/adapter.py b/nb_cli/cli/commands/adapter.py index 9a36ac8..0b54f7e 100644 --- a/nb_cli/cli/commands/adapter.py +++ b/nb_cli/cli/commands/adapter.py @@ -187,7 +187,12 @@ async def create( ctx.exit() if output_dir is None: detected: List[Choice[None]] = [ - Choice(str(x)) for x in Path(".").glob("**/adapters/") if x.is_dir() + Choice(str(x)) + for x in Path(".").glob("**/adapters/") + if x.is_dir() + and not any( + p.name.startswith(".") or p.name.startswith("_") for p in x.parents + ) ] or [ Choice(f"{x}/adapters/") for x in Path(".").glob("*/") diff --git a/nb_cli/cli/commands/plugin.py b/nb_cli/cli/commands/plugin.py index 45b64db..85102b9 100644 --- a/nb_cli/cli/commands/plugin.py +++ b/nb_cli/cli/commands/plugin.py @@ -197,7 +197,12 @@ async def create( if output_dir is None: detected: List[Choice[None]] = [ - Choice(str(d)) for d in Path(".").glob("**/plugins/") if d.is_dir() + Choice(str(d)) + for d in Path(".").glob("**/plugins/") + if d.is_dir() + and not any( + p.name.startswith("_") or p.name.startswith(".") for p in d.parents + ) ] try: output_dir = ( diff --git a/nb_cli/cli/customize.py b/nb_cli/cli/customize.py index c6785c9..6506c21 100644 --- a/nb_cli/cli/customize.py +++ b/nb_cli/cli/customize.py @@ -1,4 +1,3 @@ -from pathlib import Path from functools import partial from collections import Counter from typing import Dict, List, Optional diff --git a/nb_cli/handlers/reloader.py b/nb_cli/handlers/reloader.py index 9d70eb2..6195b64 100644 --- a/nb_cli/handlers/reloader.py +++ b/nb_cli/handlers/reloader.py @@ -1,8 +1,7 @@ -import sys import asyncio import logging from pathlib import Path -from typing import IO, Any, List, Callable, Optional, Coroutine +from typing import Any, List, Callable, Optional, Coroutine from watchfiles import awatch