python-tutorial icon indicating copy to clipboard operation
python-tutorial copied to clipboard

`ipynbname` doesn't work with password-protected Jupyter's sessions

Open edoardob90 opened this issue 8 months ago • 0 comments

If Jupyter Lab is set to use a password instead of the (default) token-based authentication, the package ipynbname doesn't work as expected and the notebook's name cannot be found.

Here's the bit from testsuite.py that causes the error:

# Line 120
def _name_from_ipynbname() -> str | None:
    try:
        return str(ipynbname.name())
    except FileNotFoundError:
        return None

# ...

# Line 134
def get_module_name(line: str, globals_dict: Dict) -> str | None:
    """Fetch the test module name"""

    module_name = (
        _name_from_line(line)
        or _name_from_ipynbname()
        or _name_from_globals(globals_dict)
    )

    return module_name

Possible solutions:

  • [ ] After %%ipytest, always append the notebook name
  • [ ] Force users not to use/set a password
  • [ ] Find an alternative to ipynbname

Here's the related issue: https://github.com/msm1089/ipynbname/issues/25

edoardob90 avatar May 12 '25 12:05 edoardob90