Skip to content

Commit 3096d80

Browse files
committed
Replace NamedTuple with dataclasses
Works around mypy bug python/mypy#7281.
1 parent 7bd4758 commit 3096d80

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

bokeh/embed/bundle.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
# Standard library imports
2424
import json
25+
from dataclasses import dataclass
2526
from os.path import (
2627
abspath,
2728
basename,
@@ -30,12 +31,7 @@
3031
join,
3132
normpath,
3233
)
33-
from typing import (
34-
Dict,
35-
List,
36-
NamedTuple,
37-
Optional,
38-
)
34+
from typing import Dict, List, Optional
3935
from warnings import warn
4036

4137
# Bokeh imports
@@ -238,7 +234,8 @@ def _query_extensions(objs, query):
238234

239235
_default_cdn_host = "https://unpkg.com"
240236

241-
class ExtensionEmbed(NamedTuple):
237+
@dataclass
238+
class ExtensionEmbed:
242239
artifact_path: str
243240
server_url: str
244241
cdn_url: Optional[str] = None

bokeh/plotting/_tools.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import itertools
2222
import re
2323
import warnings
24+
from dataclasses import dataclass
2425
from typing import (
2526
Any,
2627
Dict,
2728
Iterator,
2829
List,
29-
NamedTuple,
3030
Optional,
3131
Sequence,
3232
Tuple,
@@ -196,7 +196,8 @@ def _resolve_tools(tools: Union[str, Sequence[Union[Tool, str]]]) -> Tuple[List[
196196
return tool_objs, tool_map
197197

198198
def _collect_repeated_tools(tool_objs: List[Tool]) -> Iterator[Tool]:
199-
class Item(NamedTuple):
199+
@dataclass
200+
class Item:
200201
obj: Tool
201202
properties: Dict[str, Any]
202203

0 commit comments

Comments
 (0)