Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def check_latest_version(self, logger=logger):
url = f'https://pypi.org/pypi/{__package_name__}/json'
with suppress(Exception):
response = requests.get(url)
if response.ok and response.headers.get('Content-Type') == 'application/json':
latest = max(response.json()['releases'])
logger.debug(f'Fetched latest version from PYPI: {latest}')
if utils.totupe(__version__) < utils.totupe(latest):
logger.warning(f' ** Update available: {latest} **')
self.update_available = True