diff --git a/docker/jupyter/unsloth_branding.py b/docker/jupyter/unsloth_branding.py index 7c8db0ccfc..7a807f5377 100644 --- a/docker/jupyter/unsloth_branding.py +++ b/docker/jupyter/unsloth_branding.py @@ -58,7 +58,11 @@ SPLASH_PLUGIN_ID = "unsloth-jupyterlab:splash" LOGO_DATA_URI_PREFIX = "data:image/png;base64,iVBOR" -def resolve_paths(venv_share = None, jupyter_server_dir = None, config_dirs = None): +def resolve_paths( + venv_share = None, + jupyter_server_dir = None, + config_dirs = None, +): """Resolve the installed locations of every checked branding asset. Defaults point at the live venv + the installed jupyter_server package. Tests diff --git a/docker/unsloth_colab_compat.py b/docker/unsloth_colab_compat.py index 9899979d6b..224ce9bb88 100644 --- a/docker/unsloth_colab_compat.py +++ b/docker/unsloth_colab_compat.py @@ -39,12 +39,22 @@ import sys # Anything not listed (content/data magics like %%writefile, %%file, %%html, # %%javascript, %%latex, %%markdown, %%svg) is left untouched, because injecting # the Colab form comment into its body would corrupt the written file / output. -_SAFE_CELL_MAGICS = frozenset({ - "capture", # the Colab install pattern: suppress pip/install output - "time", "timeit", "prun", "debug", - "bash", "sh", "shell", - "python", "python2", "python3", "pypy", -}) +_SAFE_CELL_MAGICS = frozenset( + { + "capture", # the Colab install pattern: suppress pip/install output + "time", + "timeit", + "prun", + "debug", + "bash", + "sh", + "shell", + "python", + "python2", + "python3", + "pypy", + } +) def colab_cell_magic_fix(lines): @@ -63,7 +73,7 @@ def colab_cell_magic_fix(lines): # First real line. Only act if it is a cell magic that is not yet on # top (i.e. something was skipped before it). if stripped.startswith("%%") and i > 0: - name = stripped[2:].split(maxsplit=1) + name = stripped[2:].split(maxsplit = 1) name = name[0] if name else "" if name in _SAFE_CELL_MAGICS: return [line] + skipped + lines[i + 1 :] diff --git a/tests/studio/test_branding_guard.py b/tests/studio/test_branding_guard.py index dd88306dd1..372602dba8 100644 --- a/tests/studio/test_branding_guard.py +++ b/tests/studio/test_branding_guard.py @@ -74,7 +74,9 @@ def _stage(tmp_path): # config_dirs = [] keeps the tree hermetic (no host jupyter config scanned); # page_config tests write to the app-settings page_config.json directly. return ub.resolve_paths( - venv_share = str(venv_share), jupyter_server_dir = str(js_dir), config_dirs = [], + venv_share = str(venv_share), + jupyter_server_dir = str(js_dir), + config_dirs = [], ) @@ -194,10 +196,15 @@ def test_disabling_stock_plugins_is_allowed(tmp_path): """We disable the stock logo/splash ourselves -- the guard must not flag those.""" paths = _stage(tmp_path) with open(paths["page_configs"][0], "w", encoding = "utf-8") as f: - json.dump({"disabledExtensions": { - "@jupyterlab/application-extension:logo": True, - "@jupyterlab/apputils-extension:splash": True, - }}, f) + json.dump( + { + "disabledExtensions": { + "@jupyterlab/application-extension:logo": True, + "@jupyterlab/apputils-extension:splash": True, + } + }, + f, + ) assert ub.verify_branding(paths) == []