Skip to content

Commit

Permalink
Update the output type for the __new__ function in Model (bokeh#13564)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rchiodo authored Nov 30, 2023
1 parent d561e90 commit 931c912
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/bokeh/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 931c912

Please sign in to comment.