@@ -15,14 +15,15 @@ def _compare_expected_to_current_tf_version(expected_version) -> Union[None, int
1515 """
1616 actual_version = tf .version .VERSION
1717
18- # Note: We're currently only considering versions in the format 'x.y.z'
19- # (i.e., ignore RCs and multi digit versions - which is probably fine given tfs very fast major release cycles)
18+ # replaces rc, dev and b with dots to make the version strings comparable
19+ dotted_actual_version = actual_version .replace ("rc" , ".-1." )
20+ dotted_expected_version = expected_version .replace ("rc" , ".-1." )
2021
2122 # Inspection disabling reason: We really want to catch all exceptions.
2223 # noinspection PyBroadException
2324 try :
24- expected_v_splits = [int (v ) for v in expected_version [: 5 ] .split ("." )]
25- actual_v_splits = [int (v ) for v in actual_version [: 5 ] .split ("." )]
25+ expected_v_splits = [int (v ) for v in dotted_expected_version .split ("." )]
26+ actual_v_splits = [int (v ) for v in dotted_actual_version .split ("." )]
2627 except Exception :
2728 warnings .warn (
2829 f"One of the version strings '{ expected_version } ' (requested) "
@@ -35,6 +36,11 @@ def _compare_expected_to_current_tf_version(expected_version) -> Union[None, int
3536 )
3637 return None
3738
39+ if len (expected_v_splits ) > len (actual_v_splits ):
40+ actual_v_splits += [1000 ] * (len (expected_v_splits ) - len (actual_v_splits ))
41+ elif len (expected_v_splits ) < len (actual_v_splits ):
42+ expected_v_splits += [1000 ] * (len (actual_v_splits ) - len (expected_v_splits ))
43+
3844 for act , expected in zip (actual_v_splits , expected_v_splits ):
3945 if expected > act :
4046 return 1
0 commit comments