diff --git a/docker/jupyter/unsloth_branding.py b/docker/jupyter/unsloth_branding.py index 5287869a6a..7c8db0ccfc 100644 --- a/docker/jupyter/unsloth_branding.py +++ b/docker/jupyter/unsloth_branding.py @@ -58,7 +58,7 @@ 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 @@ -68,7 +68,6 @@ def resolve_paths(venv_share=None, jupyter_server_dir=None, config_dirs=None): venv_share = os.path.join(sys.prefix, "share", "jupyter") if jupyter_server_dir is None: import jupyter_server # local import: only needed for live resolution - jupyter_server_dir = os.path.dirname(jupyter_server.__file__) labext_dir = os.path.join(venv_share, "labextensions", LABEXT_NAME) @@ -79,7 +78,6 @@ def resolve_paths(venv_share=None, jupyter_server_dir=None, config_dirs=None): if config_dirs is None: try: from jupyter_core.paths import jupyter_config_path - config_dirs = jupyter_config_path() except Exception: config_dirs = [] diff --git a/tests/studio/test_branding_guard.py b/tests/studio/test_branding_guard.py index 46f94ebac5..dd88306dd1 100644 --- a/tests/studio/test_branding_guard.py +++ b/tests/studio/test_branding_guard.py @@ -45,15 +45,17 @@ def _stage(tmp_path): labext = venv_share / "labextensions" / ub.LABEXT_NAME (labext / "static").mkdir(parents = True) (labext / "package.json").write_text(json.dumps({"name": ub.LABEXT_NAME}), encoding = "utf-8") - bundle = " ".join([ - ub.PHRASE, - ub.SHORT_LABEL, - ub.COPYRIGHT, - ub.AGPL_URL, - ub.ABOUT_PLUGIN_ID, - ub.SPLASH_PLUGIN_ID, - ub.LOGO_DATA_URI_PREFIX + "AAAAdummyimagebytes", - ]) + bundle = " ".join( + [ + ub.PHRASE, + ub.SHORT_LABEL, + ub.COPYRIGHT, + ub.AGPL_URL, + ub.ABOUT_PLUGIN_ID, + ub.SPLASH_PLUGIN_ID, + ub.LOGO_DATA_URI_PREFIX + "AAAAdummyimagebytes", + ] + ) (labext / "static" / "remoteEntry.abc123.js").write_text(bundle, encoding = "utf-8") (js_dir / "templates").mkdir(parents = True) @@ -121,7 +123,6 @@ def _rebrand_labext(paths): def _strip_bundle_phrase(paths): import glob - for path in glob.glob(os.path.join(paths["labext_static"], "*.js")): with open(path, encoding = "utf-8") as f: text = f.read() @@ -131,7 +132,6 @@ def _strip_bundle_phrase(paths): def _strip_bundle_logo(paths): import glob - for path in glob.glob(os.path.join(paths["labext_static"], "*.js")): with open(path, encoding = "utf-8") as f: text = f.read() @@ -210,7 +210,16 @@ def test_attribution_sources_have_no_encoded_obfuscation(): os.path.join(src_dir, "unsloth_labext", "src", "about.ts"), os.path.join(src_dir, "unsloth_labext", "src", "splash.ts"), ] - forbidden = ["b64decode", "b64encode", "atob(", "btoa(", "fromCharCode", "unescape(", "rot13", "codecs.decode"] + forbidden = [ + "b64decode", + "b64encode", + "atob(", + "btoa(", + "fromCharCode", + "unescape(", + "rot13", + "codecs.decode", + ] for path in files: with open(path, encoding = "utf-8") as f: text = f.read() @@ -226,7 +235,9 @@ def test_canonical_phrase_is_plain_text_in_definition_files(): markers as plain constants (the runtime PHRASE value matches, even though the source wraps it across adjacent literals).""" src_dir = os.path.join(REPO, "docker", "jupyter") - ts = open(os.path.join(src_dir, "unsloth_labext", "src", "branding.ts"), encoding = "utf-8").read() + ts = open( + os.path.join(src_dir, "unsloth_labext", "src", "branding.ts"), encoding = "utf-8" + ).read() assert ub.PHRASE in ts, "branding.ts must hold the full PHRASE as one literal" py = open(os.path.join(src_dir, "unsloth_branding.py"), encoding = "utf-8").read() for marker in (ub.SHORT_LABEL, ub.COPYRIGHT, ub.SOURCE_URL, ub.AGPL_URL, ub.THEME_NAME):