Fix get_export_names and get_exporter default args#2228
Merged
krassowski merged 1 commit intojupyter:mainfrom Jul 17, 2025
Merged
Fix get_export_names and get_exporter default args#2228krassowski merged 1 commit intojupyter:mainfrom
krassowski merged 1 commit intojupyter:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These functions were annotated with
noqa: B008to silence a warning from flake8-bugbear. It turns out bugbear was onto something.get_export_namesandget_exporterwere 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 thejupyter_server_config.pyfile wouldn't remove them from the/api/nbgraderendpoint because the default values had been set to{}.This commit fixes the problem by using
Noneas the default value and callingget_config()at function call time.