@@ -833,28 +833,29 @@ def working_dir(self) -> Union[None, PathLike]:
833
833
@property
834
834
def version_info (self ) -> Tuple [int , int , int , int ]:
835
835
"""
836
- :return: tuple(int, int, int, int) tuple with integers representing the major, minor
837
- and additional version numbers as parsed from git version.
836
+ :return: tuple(int, int, int, int) tuple with integers representing the major,
837
+ minor and additional version numbers as parsed from git version.
838
838
839
839
This value is generated on demand and is cached.
840
840
"""
841
- # Use a copy of this global state, in case of a concurrent refresh.
842
- refresh_token = self ._refresh_token
843
-
844
- # Ask git for its version if we haven't done so since the last refresh.
845
- # (Refreshing is global, but version_info caching is per-instance.)
846
- if self ._version_info_token is not refresh_token :
847
- # We only use the first 4 numbers, as everything else could be strings in fact (on Windows).
848
- process_version = self ._call_process ("version" ) # Should be as default *args and **kwargs used.
849
- version_numbers = process_version .split (" " )[2 ]
850
-
851
- self ._version_info = cast (
852
- Tuple [int , int , int , int ],
853
- tuple (int (n ) for n in version_numbers .split ("." )[:4 ] if n .isdigit ()),
854
- )
855
- self ._version_info_token = refresh_token
841
+ # Refreshing is global, but version_info caching is per-instance.
842
+ refresh_token = self ._refresh_token # Copy token in case of concurrent refresh.
843
+
844
+ # Use the cached version if obtained after the most recent refresh.
845
+ if self ._version_info_token is refresh_token :
846
+ assert self ._version_info is not None , "Bug: corrupted token-check state"
847
+ return self ._version_info
848
+
849
+ # We only use the first 4 numbers, as everything else could be strings in fact (on Windows).
850
+ process_version = self ._call_process ("version" ) # Should be as default *args and **kwargs used.
851
+ version_numbers = process_version .split (" " )[2 ]
852
+
853
+ self ._version_info = cast (
854
+ Tuple [int , int , int , int ],
855
+ tuple (int (n ) for n in version_numbers .split ("." )[:4 ] if n .isdigit ()),
856
+ )
857
+ self ._version_info_token = refresh_token
856
858
857
- assert self ._version_info is not None , "Bug: token check should never let None through"
858
859
return self ._version_info
859
860
860
861
@overload
0 commit comments