@@ -75,74 +75,71 @@ def add_args_to_kwargs(
7575 kwargs [key ] = value
7676
7777def validate_kwargs (
78- kwargs : Dict [str , Any ]
78+ keyword_arguments : Dict [str , Any ]
7979 ) -> None :
80- """Validate keyword arguments(kwargs).
81- The values of keyword arguments must match the expect type and conditions. If the conditions do not match,
82- errors will be raised with the error messages and possible ways to correct the errors.
83-
84- :param kwargs: Keyword arguments to verify for query_items_change_feed API
85- :keyword mode: Must be one of the values in the Enum, 'ChangeFeedMode'.
86- If the value is 'ALL_VERSIONS_AND_DELETES', the following keywords must be in the right condition:
87- - 'partition_key_range_id': Cannot be used at any time
88- - 'is_start_from_beginning': Must be 'False'
89- - 'start_time': Must be "Now"
90- :paramtype mode: Optional[Literal["LatestVersion", "AllVersionsAndDeletes"]]
91- :keyword partition_key_range_id: Deprecated Warning.
92- :paramtype partition_key_range_id: str
93- :keyword is_start_from_beginning: Deprecated Warning. Cannot be used with 'start_time'.
94- :paramtype is_start_from_beginning: bool
95- :keyword start_time: Must be in supported types.
96- :paramtype start_time: Union[~datetime.datetime, Literal["Now", "Beginning"]]
97- :type kwargs: dict[str, Any]
80+ """Validate keyword arguments for change_feed API.
81+ The values of keyword arguments must match the expected type and conditions. If the conditions do not match,
82+ errors will be raised with the proper error messages and possible ways to correct the errors.
83+
84+ :param dict[str, Any] keyword_arguments: Keyword arguments to verify for query_items_change_feed API
85+ - Literal["LatestVersion", "AllVersionsAndDeletes"] mode: Must be one of the values in the Enum,
86+ 'ChangeFeedMode'. If the value is 'ALL_VERSIONS_AND_DELETES', the following keywords must be in the right
87+ conditions:
88+ - 'partition_key_range_id': Cannot be used at any time
89+ - 'is_start_from_beginning': Must be 'False'
90+ - 'start_time': Must be "Now"
91+ - str partition_key_range_id: Deprecated Warning.
92+ - bool is_start_from_beginning: Deprecated Warning. Cannot be used with 'start_time'.
93+ - Union[~datetime.datetime, Literal["Now", "Beginning"]] start_time: Must be in supported types.
9894 """
9995 # Filter items with value None
100- kwargs = {key : value for key , value in kwargs .items () if value is not None }
96+ keyword_arguments = {key : value for key , value in keyword_arguments .items () if value is not None }
10197
10298 # Validate the keyword arguments
103- if "mode" in kwargs :
104- mode = kwargs ["mode" ]
99+ if "mode" in keyword_arguments :
100+ mode = keyword_arguments ["mode" ]
105101 if mode not in CHANGE_FEED_MODES :
106102 raise ValueError (
107- f"Invalid mode was used: '{ kwargs ['mode' ]} '."
103+ f"Invalid mode was used: '{ keyword_arguments ['mode' ]} '."
108104 f" Supported modes are { CHANGE_FEED_MODES } ." )
109105
110106 if mode == 'AllVersionsAndDeletes' :
111- if "partition_key_range_id" in kwargs :
107+ if "partition_key_range_id" in keyword_arguments :
112108 raise ValueError (
113109 "'AllVersionsAndDeletes' mode is not supported if 'partition_key_range_id'"
114110 " was used. Please use 'feed_range' instead." )
115- if "is_start_from_beginning" in kwargs and kwargs ["is_start_from_beginning" ] is not False :
111+ if ("is_start_from_beginning" in keyword_arguments
112+ and keyword_arguments ["is_start_from_beginning" ] is not False ):
116113 raise ValueError (
117114 "'AllVersionsAndDeletes' mode is only supported if 'is_start_from_beginning'"
118115 " is 'False'. Please use 'is_start_from_beginning=False' or 'continuation' instead." )
119- if "start_time" in kwargs and kwargs ["start_time" ] != "Now" :
116+ if "start_time" in keyword_arguments and keyword_arguments ["start_time" ] != "Now" :
120117 raise ValueError (
121118 "'AllVersionsAndDeletes' mode is only supported if 'start_time' is 'Now'."
122119 " Please use 'start_time=\" Now\" ' or 'continuation' instead." )
123120
124- if "partition_key_range_id" in kwargs :
121+ if "partition_key_range_id" in keyword_arguments :
125122 warnings .warn (
126123 "'partition_key_range_id' is deprecated. Please pass in 'feed_range' instead." ,
127124 DeprecationWarning
128125 )
129126
130- if "is_start_from_beginning" in kwargs :
127+ if "is_start_from_beginning" in keyword_arguments :
131128 warnings .warn (
132129 "'is_start_from_beginning' is deprecated. Please pass in 'start_time' instead." ,
133130 DeprecationWarning
134131 )
135132
136- if not isinstance (kwargs ["is_start_from_beginning" ], bool ):
133+ if not isinstance (keyword_arguments ["is_start_from_beginning" ], bool ):
137134 raise TypeError (
138135 f"'is_start_from_beginning' must be 'bool' type,"
139- f" but given '{ type (kwargs ['is_start_from_beginning' ]).__name__ } '." )
136+ f" but given '{ type (keyword_arguments ['is_start_from_beginning' ]).__name__ } '." )
140137
141- if kwargs ["is_start_from_beginning" ] is True and "start_time" in kwargs :
138+ if keyword_arguments ["is_start_from_beginning" ] is True and "start_time" in keyword_arguments :
142139 raise ValueError ("'is_start_from_beginning' and 'start_time' are exclusive, please only set one of them." )
143140
144- if "start_time" in kwargs :
145- if not isinstance (kwargs ['start_time' ], datetime ):
146- if kwargs ['start_time' ].lower () not in ["now" , "beginning" ]:
141+ if "start_time" in keyword_arguments :
142+ if not isinstance (keyword_arguments ['start_time' ], datetime ):
143+ if keyword_arguments ['start_time' ].lower () not in ["now" , "beginning" ]:
147144 raise ValueError (
148- f"'start_time' must be either 'Now' or 'Beginning', but given '{ kwargs ['start_time' ]} '." )
145+ f"'start_time' must be either 'Now' or 'Beginning', but given '{ keyword_arguments ['start_time' ]} '." )
0 commit comments