☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Correct linting for figures and show

Community Supportbokeh
jonathansailing
jonathansailing

I am not sure if this is a bokeh bug, or I am confusing something, but I get the following warning from Pylance, when using this very minimal code:

Argument of type “Model” cannot be assigned to parameter “obj” of type “UIElement | Application | ModifyDoc” in function “show”
Type “Model” cannot be assigned to type “UIElement | Application | ModifyDoc”
“Model” is incompatible with “UIElement”
“Model” is incompatible with “Application”
Type “Model” cannot be assigned to type “ModifyDoc”

from bokeh.plotting import figure, show
p = figure()
show(p)

if I change the second line to p: figure = figure() I don’t get a warning in the last line, but a warning in the second line:

Expression of type “Model” cannot be assigned to declared type “figure”
“Model” is incompatible with “figure”

Any thoughts on this?

⌁   Link to post
Bryan
Bryan

figure inherits from Plot which inherits from LayoutDOM which inherits from UIElement. So I have to conclude that the annotations are correct as given in the Bokeh source code, and would also note that mypy (which is run on the codebase continually on GitHub) is happy with this code:

dev-311 ❯ cat foo.py
from bokeh.plotting import figure, show
p = figure()
show(p)

dev-311 ❯ mypy foo.py
Success: no issues found in 1 source file

OTOH Bokeh models (like figure) have complicated metaclasses, so maybe there is something about that that confuses pylance. I don’t have any concrete suggestions, I am afraid.

⌁   Link to post
Bryan
Bryan

@jonathansailing FYI it looks like this might actually have been coincidentally resolved in a PR today

⌁   Link to post

End of archived discussion · Replies are disabled