@@ -257,32 +257,30 @@ def __init__(self):
257257 @property
258258 def installed_version (self ) -> packaging .version .Version :
259259 """Return the parsed version of pandas-gbq"""
260- if self ._installed_version is None :
261- try :
262- import pandas_gbq # type: ignore
260+ if self ._installed_version is not None :
261+ return self ._installed_version
263262
264- self ._installed_version = packaging .version .parse (
265- getattr (pandas_gbq , "__version__" , "0.0.0" )
266- )
267- except Exception :
268- self ._installed_version = packaging .version .parse ("0.0.0" )
263+ try :
264+ import pandas_gbq # type: ignore
269265
270- return self ._installed_version
266+ return packaging .version .parse (
267+ getattr (pandas_gbq , "__version__" , "0.0.0" )
268+ )
269+ except Exception :
270+ return packaging .version .parse ("0.0.0" )
271271
272272 @property
273273 def delegation_api_version (self ) -> int :
274274 """Return the delegation API version of pandas-gbq if installed, otherwise 0."""
275- if self ._delegation_api_version is None :
276- try :
277- import pandas_gbq # type: ignore
275+ if self ._delegation_api_version is not None :
276+ return self ._delegation_api_version
278277
279- self ._delegation_api_version = getattr (
280- pandas_gbq , "_internal_delegation_api_version" , 0
281- )
282- except Exception :
283- self ._delegation_api_version = 0
278+ try :
279+ import pandas_gbq # type: ignore
284280
285- return self ._delegation_api_version
281+ return int (getattr (pandas_gbq , "_internal_delegation_api_version" , 0 ))
282+ except Exception :
283+ return 0
286284
287285 @property
288286 def is_delegation_supported (self ) -> bool :
0 commit comments