@@ -371,11 +371,16 @@ def check(self, context: Context) -> None:
371371 @classmethod
372372 def from_parameters (
373373 cls ,
374- project_names : list [str ] | None = None ,
374+ project_names : Iterable [str ] | None = None ,
375375 ** kwargs ,
376376 ) -> ProjectNamesRestriction | None :
377377 if project_names is not None :
378- return cls (project_names = project_names )
378+ if isinstance (project_names , str ):
379+ raise exceptions .InvalidRestriction (
380+ "project_names should be an iterable of strings. "
381+ "Received a single string not wrapped in an iterable."
382+ )
383+ return cls (project_names = list (project_names ))
379384 return None
380385
381386
@@ -435,11 +440,16 @@ def check(self, context: Context) -> None:
435440 @classmethod
436441 def from_parameters (
437442 cls ,
438- project_ids : list [str ] | None = None ,
443+ project_ids : Iterable [str ] | None = None ,
439444 ** kwargs ,
440445 ) -> ProjectIDsRestriction | None :
441446 if project_ids is not None :
442- return cls (project_ids = project_ids )
447+ if isinstance (project_ids , str ):
448+ raise exceptions .InvalidRestriction (
449+ "project_ids should be an iterable of strings. "
450+ "Received a single string not wrapped in an iterable."
451+ )
452+ return cls (project_ids = list (project_ids ))
443453 return None
444454
445455
@@ -598,11 +608,16 @@ def check(self, context: Context) -> None:
598608 @classmethod
599609 def from_parameters (
600610 cls ,
601- legacy_project_names : list [str ] | None = None ,
611+ legacy_project_names : Iterable [str ] | None = None ,
602612 ** kwargs ,
603613 ) -> LegacyProjectNamesRestriction | None :
604614 if legacy_project_names is not None :
605- return cls (project_names = legacy_project_names )
615+ if isinstance (legacy_project_names , str ):
616+ raise exceptions .InvalidRestriction (
617+ "legacy_project_names should be an iterable of strings. "
618+ "Received a single string not wrapped in an iterable."
619+ )
620+ return cls (project_names = list (legacy_project_names ))
606621 return None
607622
608623
0 commit comments