@@ -151,13 +151,14 @@ def _update_last_check(self) -> None:
151151 except IOError :
152152 pass
153153
154- def check_for_update (self , current_version : str ) -> Optional [str ]:
154+ def check_for_update (self , current_version : str , use_cache : bool = True ) -> Optional [str ]:
155155 """Check if an update is available for the current version.
156156
157- Respects the update check frequency (daily/weekly) based on version type
157+ Respects the update check frequency (daily/weekly) based on the version type
158158
159159 Args:
160160 current_version: The current version string of the CLI
161+ use_cache: If True, use the cached timestamp to determine if an update check is needed
161162
162163 Returns:
163164 str | None: The latest version string if an update is recommended,
@@ -166,20 +167,20 @@ def check_for_update(self, current_version: str) -> Optional[str]:
166167 current_parts , current_is_pre = self ._parse_version (current_version )
167168
168169 # Check if we should perform the update check based on frequency
169- if not self ._should_check_update (current_is_pre ):
170+ if use_cache and not self ._should_check_update (current_is_pre ):
170171 return None
171172
172173 latest_version = self .get_latest_version ()
173174 if not latest_version :
174175 return None
175176
176177 # Update the last check timestamp
177- self ._update_last_check ()
178+ use_cache and self ._update_last_check ()
178179
179180 latest_parts , latest_is_pre = self ._parse_version (latest_version )
180181 return _compare_versions (current_parts , latest_parts , current_is_pre , latest_is_pre , latest_version )
181182
182- def check_and_notify_update (self , current_version : str , use_color : bool = True , bypass_cache : bool = False ) -> None :
183+ def check_and_notify_update (self , current_version : str , use_color : bool = True , use_cache : bool = True ) -> None :
183184 """Check for updates and display a notification if a new version is available.
184185
185186 Performs the version check and displays a formatted message with update instructions
@@ -191,15 +192,10 @@ def check_and_notify_update(self, current_version: str, use_color: bool = True,
191192 Args:
192193 current_version: Current version of the CLI
193194 use_color: If True, use colored output in the terminal
194- bypass_cache : If True, ignore the cache and check for updates immediately
195+ use_cache : If True, use the cached timestamp to determine if an update check is needed
195196 """
196- if bypass_cache :
197- latest_version = self .get_latest_version ()
198- should_update = latest_version and latest_version != current_version
199- else :
200- latest_version = self .check_for_update (current_version )
201- should_update = bool (latest_version )
202-
197+ latest_version = self .check_for_update (current_version , use_cache )
198+ should_update = bool (latest_version )
203199 if should_update :
204200 update_message = (
205201 '\n New version of cycode available! '
0 commit comments