Skip to content

Commit 8b226f4

Browse files
committed
fix: formatting and type checking error
1 parent dfdaf03 commit 8b226f4

1 file changed

Lines changed: 5 additions & 17 deletions

File tree

src/pyobsplot/parsing.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
class SpecParser:
16-
1716
def __init__(
1817
self,
1918
renderer: Literal["widget", "jsdom"] = "widget",
@@ -41,11 +40,7 @@ def spec(self):
4140
return self._spec
4241

4342
def set_spec(self, value: dict, *, force_figure: bool = False):
44-
if (
45-
"pyobsplot-type" in value
46-
and value["pyobsplot-type"] == "function"
47-
and value["module"] == "Plot"
48-
):
43+
if "pyobsplot-type" in value and value["pyobsplot-type"] == "function" and value["module"] == "Plot":
4944
value = {"marks": [value]}
5045
if force_figure:
5146
value["figure"] = True
@@ -134,11 +129,7 @@ def parse(self, spec: Any) -> Any:
134129
if isinstance(spec, str) and spec[0:28] == '{"type": "FeatureCollection"':
135130
spec = json.loads(spec)
136131
# If Geojson as dict, handle caching, don't parse, add type and returns as is
137-
if (
138-
isinstance(spec, dict)
139-
and "type" in spec
140-
and spec["type"] == "FeatureCollection"
141-
):
132+
if isinstance(spec, dict) and "type" in spec and spec["type"] == "FeatureCollection":
142133
index = self.cache_index(spec)
143134
if index is None:
144135
self.data.append(spec)
@@ -184,13 +175,10 @@ def parse(self, spec: Any) -> Any:
184175
return {"pyobsplot-type": "datetime", "value": spec.isoformat()}
185176
# Handling of JavaScript methods as objects, such as "Math.sin"
186177
# Manually call the parsed result and add a special "function-object" type
187-
if (
188-
callable(spec)
189-
and isinstance(spec(), dict)
190-
and spec()["pyobsplot-type"] == "function"
191-
):
178+
if callable(spec):
192179
out = spec()
193-
out["pyobsplot-type"] = "function-object"
180+
if isinstance(out, dict) and out["pyobsplot-type"] == "function":
181+
out["pyobsplot-type"] = "function-object"
194182
return out
195183
return spec
196184

0 commit comments

Comments
 (0)