From 931c912f2fca2b659f7d8b463640e1a6198fb770 Mon Sep 17 00:00:00 2001 From: Rich Chiodo Date: Thu, 30 Nov 2023 14:10:45 -0800 Subject: [PATCH] Update the output type for the __new__ function in Model (#13564) * Update the output type for the __new__ function in Model This fixes an issue with typecheckers for detecting the return value of creating a Model * Update model.py to not use any return type for __new__ * Update model.py to use self again * Update for isort issues --- src/bokeh/model/model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bokeh/model/model.py b/src/bokeh/model/model.py index 7bea7204bb6..3e39507cd35 100644 --- a/src/bokeh/model/model.py +++ b/src/bokeh/model/model.py @@ -39,6 +39,8 @@ from .util import HasDocumentRef, collect_models, visit_value_and_its_immediate_references if TYPE_CHECKING: + from typing_extensions import Self + from ..core.has_props import Setter from ..core.query import SelectorType from ..document import Document @@ -87,7 +89,7 @@ def __init_subclass__(cls): _id: ID - def __new__(cls, *args: Any, id: ID | None = None, **kwargs: Any) -> Model: + def __new__(cls, *args: Any, id: ID | None = None, **kwargs: Any) -> Self: obj = super().__new__(cls) # Setting 'id' implies deferred initialization, which means properties