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

[BUG] Typing of layouts.gridplot expects wrong type if ncols given #13897

Open
levsa opened this issue May 15, 2024 · 0 comments · May be fixed by #13914
Open

[BUG] Typing of layouts.gridplot expects wrong type if ncols given #13897

levsa opened this issue May 15, 2024 · 0 comments · May be fixed by #13914

Comments

@levsa
Copy link

levsa commented May 15, 2024

Software versions

Python version : 3.10.2 (main, Oct 11 2022, 14:44:11) [Clang 14.0.0 (clang-1400.0.29.102)]
IPython version : (not installed)
Tornado version : 6.0.3
Bokeh version : 3.4.1
BokehJS static path : ./.pyenv/versions/3.10.2/envs/dev@3.10.2/lib/python3.10/site-packages/bokeh/server/static
node.js version : v18.4.0
npm version : 8.12.1
jupyter_bokeh version : (not installed)
Operating system : macOS-14.4.1-arm64-arm-64bit

Browser name and version

No response

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

mypy check to pass

Observed behavior

mypy finds an error:

error: Argument 1 to "gridplot" has incompatible type "list[figure]"; expected "list[list[Any | None]]"  [arg-type]

Example code

from bokeh import layouts
from bokeh.plotting import figure

figures = [figure(title="figure_1"), figure(title="figure_2")]
grid = layouts.column(layouts.gridplot(figures, ncols=3), data_table)

Stack traceback or browser console output

Proposed fix:

@overload
def gridplot(
    children: list[UIElement | None],
    *,
    sizing_mode: SizingModeType | None = None,
    toolbar_location: LocationType | None = "above",
    ncols: int,
    width: int | None = None,
    height: int | None = None,
    toolbar_options: dict[ToolbarOptions, Any] | None = None,
    merge_tools: bool = True,
) -> GridPlot:
    ...


@overload
def gridplot(
    children: list[list[UIElement | None]],
    *,
    sizing_mode: SizingModeType | None = None,
    toolbar_location: LocationType | None = "above",
    ncols: None,
    width: int | None = None,
    height: int | None = None,
    toolbar_options: dict[ToolbarOptions, Any] | None = None,
    merge_tools: bool = True,
) -> GridPlot:
    ...


def gridplot(
    children: list[UIElement | None] | list[list[UIElement | None]],
    *,
    sizing_mode: SizingModeType | None = None,
    toolbar_location: LocationType | None = "above",
    ncols: int | None = None,
    width: int | None = None,
    height: int | None = None,
    toolbar_options: dict[ToolbarOptions, Any] | None = None,
    merge_tools: bool = True,
) -> GridPlot:
    if ncols:
    
    # implementation here

Screenshots

No response

@levsa levsa added the TRIAGE label May 15, 2024
@mosc9575 mosc9575 added this to the 3.5 milestone May 27, 2024
@mosc9575 mosc9575 linked a pull request May 27, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants