Skip to content

Fix get_export_names and get_exporter default args#2228

Merged
krassowski merged 1 commit intojupyter:mainfrom
shreve:exporter-name-fix
Jul 17, 2025
Merged

Fix get_export_names and get_exporter default args#2228
krassowski merged 1 commit intojupyter:mainfrom
shreve:exporter-name-fix

Conversation

@shreve
Copy link
Contributor

@shreve shreve commented Jul 16, 2025

These functions were annotated with noqa: B008 to silence a warning from flake8-bugbear. It turns out bugbear was onto something.

get_export_names and get_exporter were defined with a default argument, config=get_config(). The problem is that this function call is executed once when the function is defined, not each time the function is called. I encountered this problem in a JupyterLab server where disabling exporters in the jupyter_server_config.py file wouldn't remove them from the /api/nbgrader endpoint because the default values had been set to {}.

This commit fixes the problem by using None as the default value and calling get_config() at function call time.

These functions were annotated with `noqa: B008` to silence a warning
from flake8-bugbear. It turns out bugbear was onto something.

`get_export_names` and `get_exporter` were defined a default argument,
`config=get_config()`. The problem is that this function call is
executed once when the function is defined, not each time the function
is called. I encountered this problem in a JupyterLab server where
disabling exporters in the `jupyter_server_config.py` file wouldn't
remove them from the `/api/nbgrader` endpoint because the default values
had been set to `{}`.

This commit fixes the problem by using `None` as the default value and
calling `get_config()` at function call time.
@krassowski krassowski added the bug label Jul 16, 2025
Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@krassowski krassowski merged commit e9d892e into jupyter:main Jul 17, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants