[update] Prepare to remove Python 3.6 support

This commit is contained in:
pukkandan 2022-07-17 17:36:15 +05:30
parent f5e438a976
commit 24093d52a7
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39
2 changed files with 17 additions and 9 deletions

View file

@ -588,8 +588,8 @@ def __init__(self, params=None, auto_init=True):
current_version = sys.version_info[:2] current_version = sys.version_info[:2]
if current_version < MIN_RECOMMENDED: if current_version < MIN_RECOMMENDED:
msg = ('Support for Python version %d.%d has been deprecated. ' msg = ('Support for Python version %d.%d has been deprecated. '
'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details. ' 'See https://github.com/yt-dlp/yt-dlp/issues/3764 for more details.'
'You will recieve only one more update on this version') '\n You will no longer recieve updates on this version')
if current_version < MIN_SUPPORTED: if current_version < MIN_SUPPORTED:
msg = 'Python version %d.%d is no longer supported' msg = 'Python version %d.%d is no longer supported'
self.deprecation_warning( self.deprecation_warning(

View file

@ -88,8 +88,7 @@ def __init__(self, ydl):
@functools.cached_property @functools.cached_property
def _tag(self): def _tag(self):
latest = self._get_version_info('latest')['tag_name'] if version_tuple(__version__) >= version_tuple(self.latest_version):
if version_tuple(__version__) >= version_tuple(latest):
return 'latest' return 'latest'
identifier = f'{detect_variant()} {system_identifier()}' identifier = f'{detect_variant()} {system_identifier()}'
@ -113,9 +112,16 @@ def current_version(self):
@property @property
def new_version(self): def new_version(self):
"""Version of the latest release""" """Version of the latest release we can update to"""
if self._tag.startswith('tags/'):
return self._tag[5:]
return self._get_version_info(self._tag)['tag_name'] return self._get_version_info(self._tag)['tag_name']
@property
def latest_version(self):
"""Version of the latest release"""
return self._get_version_info('latest')['tag_name']
@property @property
def has_update(self): def has_update(self):
"""Whether there is an update available""" """Whether there is an update available"""
@ -161,13 +167,15 @@ def check_update(self):
"""Report whether there is an update available""" """Report whether there is an update available"""
try: try:
self.ydl.to_screen( self.ydl.to_screen(
f'Latest version: {self.new_version}, Current version: {self.current_version}') f'Latest version: {self.latest_version}, Current version: {self.current_version}')
if not self.has_update:
if self._tag == 'latest':
return self.ydl.to_screen(f'yt-dlp is up to date ({__version__})')
return self.ydl.report_warning(
'yt-dlp cannot be updated any further since you are on an older Python version')
except Exception: except Exception:
return self._report_network_error('obtain version info', delim='; Please try again later or') return self._report_network_error('obtain version info', delim='; Please try again later or')
if not self.has_update:
return self.ydl.to_screen(f'yt-dlp is up to date ({__version__})')
if not is_non_updateable(): if not is_non_updateable():
self.ydl.to_screen(f'Current Build Hash {_sha256_file(self.filename)}') self.ydl.to_screen(f'Current Build Hash {_sha256_file(self.filename)}')
return True return True