@@ -17,6 +17,19 @@ class WorkspaceVersionMismatchError(exc.ConfigException):
1717# enough to suggest the clone is genuinely stale.
1818_STALENESS_WINDOW_DAYS = 30
1919
20+ # Every library init (autofit, autogalaxy, autolens, ...) calls check_version,
21+ # so without dedup a byte-identical warning prints once per library in the
22+ # import chain. Python's own warning registry does not dedupe here because
23+ # third-party imports between the calls invalidate it.
24+ _warned_messages = set ()
25+
26+
27+ def _warn_once (message ):
28+ if message in _warned_messages :
29+ return
30+ _warned_messages .add (message )
31+ warnings .warn (message )
32+
2033
2134def _read_general_yaml (workspace_root ):
2235 """
@@ -224,7 +237,7 @@ def check_version(library_version, workspace_root=None):
224237 if floor_version is None or floor_version == "" :
225238 if _is_source_checkout (root ):
226239 return
227- warnings . warn (_missing_version_warning (root , library_version ))
240+ _warn_once (_missing_version_warning (root , library_version ))
228241 return
229242
230243 if floor_version == library_version :
@@ -234,7 +247,7 @@ def check_version(library_version, workspace_root=None):
234247 library_parsed = _parse_version (library_version )
235248
236249 if floor_parsed is None or library_parsed is None :
237- warnings . warn (
250+ _warn_once (
238251 _unparseable_mismatch_message (floor_version , library_version , root )
239252 )
240253 return
@@ -252,4 +265,4 @@ def check_version(library_version, workspace_root=None):
252265 and library_date is not None
253266 and (library_date - floor_date ).days > _STALENESS_WINDOW_DAYS
254267 ):
255- warnings . warn (_stale_workspace_message (floor_version , library_version , root ))
268+ _warn_once (_stale_workspace_message (floor_version , library_version , root ))
0 commit comments