Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the method for determining kernel language #354

Merged
merged 3 commits into from
Aug 14, 2024

Commits on Aug 9, 2024

  1. Update the method for determining kernel language

    The previous algorithm for `getNotebookType()` was based on getting the
    kernel spec out of the current notebook. This is a problem when format
    is triggered by, for example, `jupyterlab-autosave-on-focus-change`,
    immediately after notebook creation. In that case, the language is
    determined to be `null` and errors arise.
    
    Now the `onSave()` handler waits for the `sessionContext` to be ready,
    then `getNotebookType()` gets the same kernel spec info from the session
    rather than the loaded notebook.
    shreve committed Aug 9, 2024
    Configuration menu
    Copy the full SHA
    62b57c3 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2024

  1. Make metadata access safer at runtime

    The `!` operator is a type assertion that the attribute is not null, but
    does nothing at runtime to ensure this is the case. I haven't yet found
    reproduction steps for this failure, but I encountered a case where
    accessing `model!.sharedModel` threw an error. This commit adds optional
    chaining operators, which do provide protection at runtime.
    shreve committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    92c805d View commit details
    Browse the repository at this point in the history
  2. Fall back to session check if metadata is missing

    `getNotebookType()` has two ways to determine the language. If the
    metadata check fails, it falls through to the current session check.
    Previously, if metadata was `null`, the method would return early.
    shreve committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    50e5910 View commit details
    Browse the repository at this point in the history