@@ -61,8 +61,10 @@ def handle(self, *args, **options) -> None:
6161 scale : str = options ["scale" ]
6262 truncate_first : bool = options ["truncate_first" ]
6363
64- selected_seed = options ["seed" ] if options ["seed" ] is not None else int (time .time ())
65- random .seed (selected_seed )
64+ selected_seed = (
65+ options ["seed" ] if options ["seed" ] is not None else int (time .time ())
66+ )
67+ random .seed (selected_seed ) # nosec B311
6668 self .stdout .write (f"Seed used: { selected_seed } " )
6769
6870 should_seed_cms = dataset in {"cms" , "both" }
@@ -98,7 +100,9 @@ def handle(self, *args, **options) -> None:
98100 )
99101
100102 @classmethod
101- def _seed_metrics_data (cls , * , scale_config : dict [str , int ], truncate_first : bool ) -> dict [str , int ]:
103+ def _seed_metrics_data (
104+ cls , * , scale_config : dict [str , int ], truncate_first : bool
105+ ) -> dict [str , int ]:
102106 if truncate_first :
103107 cls ._truncate_metrics_data ()
104108
@@ -111,23 +115,31 @@ def _seed_metrics_data(cls, *, scale_config: dict[str, int], truncate_first: boo
111115 sub_themes = cls ._bulk_create (
112116 SubTheme ,
113117 [
114- SubTheme (name = f"SubTheme { index + 1 } " , theme = themes [index % len (themes )])
118+ SubTheme (
119+ name = f"SubTheme { index + 1 } " , theme = themes [index % len (themes )]
120+ )
115121 for index in range (6 )
116122 ],
117123 )
118124
119125 topics = cls ._bulk_create (
120126 Topic ,
121127 [
122- Topic (name = f"Topic { index + 1 } " , sub_theme = sub_themes [index % len (sub_themes )])
128+ Topic (
129+ name = f"Topic { index + 1 } " ,
130+ sub_theme = sub_themes [index % len (sub_themes )],
131+ )
123132 for index in range (12 )
124133 ],
125134 )
126135
127136 metrics = cls ._bulk_create (
128137 Metric ,
129138 [
130- Metric (name = f"Random Metric { index + 1 } " , topic = topics [index % len (topics )])
139+ Metric (
140+ name = f"Random Metric { index + 1 } " ,
141+ topic = topics [index % len (topics )],
142+ )
131143 for index in range (scale_config ["metrics" ])
132144 ],
133145 )
@@ -207,8 +219,10 @@ def _seed_time_series_rows(
207219 for geography in geographies :
208220 for day_offset in range (days ):
209221 current_date = start_date + timedelta (days = day_offset )
210- base_value = random .uniform (5.0 , 250.0 ) # noqa: S311
211- metric_value = round (base_value + random .uniform (- 10.0 , 10.0 ), 2 ) # noqa: S311
222+ base_value = random .uniform (5.0 , 250.0 ) # nosec B311
223+ metric_value = round (
224+ base_value + random .uniform (- 10.0 , 10.0 ), 2
225+ ) # nosec B311
212226 epidemiological_week = current_date .isocalendar ().week
213227
214228 core_rows .append (
@@ -229,7 +243,9 @@ def _seed_time_series_rows(
229243 )
230244
231245 if len (core_rows ) >= batch_size :
232- CoreTimeSeries .objects .bulk_create (core_rows , batch_size = batch_size )
246+ CoreTimeSeries .objects .bulk_create (
247+ core_rows , batch_size = batch_size
248+ )
233249 core_count += len (core_rows )
234250 core_rows = []
235251
@@ -257,7 +273,9 @@ def _seed_time_series_rows(
257273 )
258274
259275 if len (api_rows ) >= batch_size :
260- APITimeSeries .objects .bulk_create (api_rows , batch_size = batch_size )
276+ APITimeSeries .objects .bulk_create (
277+ api_rows , batch_size = batch_size
278+ )
261279 api_count += len (api_rows )
262280 api_rows = []
263281
0 commit comments