[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
0a8ae80b44
commit
2c190aaaca
3 changed files with 34 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 :]
|
||||
|
|
|
|||
|
|
@ -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) == []
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue