xinbinhuang commented on a change in pull request #17940:
URL: https://github.com/apache/airflow/pull/17940#discussion_r699802753



##########
File path: airflow/utils/weekday.py
##########
@@ -45,3 +46,27 @@ def get_weekday_number(cls, week_day_str):
             raise AttributeError(f'Invalid Week Day passed: "{week_day_str}"')
 
         return cls[sanitized_week_day_str]
+
+    @classmethod
+    def convert(cls, day: Union[str, 'WeekDay']) -> int:
+        """Helper function that returns the day number in the week"""
+        if isinstance(day, WeekDay):
+            return day
+        return cls.get_weekday_number(week_day_str=day)
+
+    @classmethod
+    def validate_week_day(cls, day_iterable: Union[str, 'WeekDay', Set[str], 
List[str]]):
+        """Validate each item of iterable and create a set to ease compare of 
values"""
+        if not isinstance(day_iterable, Iterable):
+            if isinstance(day_iterable, WeekDay):
+                day_iterable = {day_iterable}
+            else:
+                raise TypeError(
+                    "Unsupported Type for is_today parameter: {}."
+                    "Input should be iterable type."
+                    "str, set, list, dict or Weekday enum 
type".format(type(day_iterable))

Review comment:
       ```suggestion
                       "Unsupported Type for is_today parameter: 
{type(day_iterable)}. "
                       "Input should be iterable type: "
                       "str, set, list, dict or Weekday enum type"
   ```
   
   nit: 
   - I think f-string here would be better as it locates closer to where it's 
actually used.
   - I believe multi-lines strings are concatenated without the space between 
the sentences, so we need to add them at the end for each line




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to