Skip to content

Commit bc16cb4

Browse files
committed
fix: Properly check for dict type before running _set_data
1 parent 23d3fab commit bc16cb4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

policyengine/simulation.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import h5py
2929
from pathlib import Path
3030
import pandas as pd
31-
from typing import Type, Optional
31+
from typing import Type, Any, Optional
3232
from functools import wraps, partial
3333
from typing import Callable
3434
import importlib
@@ -37,7 +37,7 @@
3737
CountryType = Literal["uk", "us"]
3838
ScopeType = Literal["household", "macro"]
3939
DataType = (
40-
str | dict | Dataset | None
40+
str | dict[Any, Any] | Dataset | None
4141
) # Needs stricter typing. Any==policyengine_core.data.Dataset, but pydantic refuses for some reason.
4242
TimePeriodType = int
4343
ReformType = ParametricReform | Type[StructuralReform] | None
@@ -99,7 +99,10 @@ class Simulation:
9999
def __init__(self, **options: SimulationOptions):
100100
self.options = SimulationOptions(**options)
101101
self.check_model_version()
102-
if not isinstance(self.options.data, Dataset):
102+
if not isinstance(self.options.data, dict) and not isinstance(
103+
self.options.data, Dataset
104+
):
105+
print(type(self.options.data), sys.stderr)
103106
self._set_data(self.options.data)
104107
self._initialise_simulations()
105108
self.check_data_version()

0 commit comments

Comments
 (0)