diff --git a/pyproject.toml b/pyproject.toml index 84a30fdfbd..e228f81d36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -322,6 +322,7 @@ select = [ "SIM", # flake8-simplify "TID251", # banned-api "TD", # flake8-todos + "TRY201", # verbose-raise "PLC", # Pylint Convention "PLE", # Pylint Error "PLW", # Pylint Warning diff --git a/yt_dlp/extractor/adn.py b/yt_dlp/extractor/adn.py index 47b0a0b0f9..6612b21a42 100644 --- a/yt_dlp/extractor/adn.py +++ b/yt_dlp/extractor/adn.py @@ -225,7 +225,7 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text''' break except ExtractorError as e: if not isinstance(e.cause, HTTPError): - raise e + raise if e.cause.status == 401: # This usually goes away with a different random pkcs1pad, so retry diff --git a/yt_dlp/extractor/audius.py b/yt_dlp/extractor/audius.py index 830975a27d..82608fbb87 100644 --- a/yt_dlp/extractor/audius.py +++ b/yt_dlp/extractor/audius.py @@ -62,7 +62,7 @@ class AudiusBaseIE(InfoExtractor): if 'Failed to parse JSON' in str(exc): raise ExtractorError('An error occurred while receiving data. Try again', expected=True) - raise exc + raise return self._get_response_data(response) def _resolve_url(self, url, item_id): diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 55e77581d3..5e75b73b99 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -780,7 +780,7 @@ class InfoExtractor: except ExtractorError as e: e.video_id = e.video_id or self.get_temp_id(url) e.ie = e.ie or self.IE_NAME - e.traceback = e.traceback or sys.exc_info()[2] + e.traceback = e.traceback or e.__traceback__ raise except IncompleteRead as e: raise ExtractorError('A network error has occurred.', cause=e, expected=True, video_id=self.get_temp_id(url)) @@ -1194,10 +1194,10 @@ class InfoExtractor: while True: try: return self.__download_webpage(url_or_request, video_id, note, errnote, None, fatal, *args, **kwargs) - except IncompleteRead as e: + except IncompleteRead: try_count += 1 if try_count >= tries: - raise e + raise self._sleep(timeout, video_id) def report_warning(self, msg, video_id=None, *args, only_once=False, **kwargs): diff --git a/yt_dlp/extractor/rcti.py b/yt_dlp/extractor/rcti.py index a6b0a4fa8d..1a5e41e83e 100644 --- a/yt_dlp/extractor/rcti.py +++ b/yt_dlp/extractor/rcti.py @@ -195,7 +195,7 @@ class RCTIPlusIE(RCTIPlusBaseIE): if isinstance(e.cause, HTTPError) and e.cause.status == 403: self.raise_geo_restricted(countries=['ID'], metadata_available=True) else: - raise e + raise for f in formats: if 'akamaized' in f['url'] or 'cloudfront' in f['url']: f.setdefault('http_headers', {})['Referer'] = 'https://www.rctiplus.com/' # Referer header is required for akamai/cloudfront CDNs @@ -272,7 +272,7 @@ class RCTIPlusSeriesIE(RCTIPlusBaseIE): except ExtractorError as e: if 'not found' in str(e): return [] - raise e + raise if total_pages <= 0: return [] diff --git a/yt_dlp/extractor/trueid.py b/yt_dlp/extractor/trueid.py index 183364b401..c56545d82a 100644 --- a/yt_dlp/extractor/trueid.py +++ b/yt_dlp/extractor/trueid.py @@ -89,7 +89,7 @@ class TrueIDIE(InfoExtractor): f'https://{domain}/cmsPostProxy/contents/video/{video_id}/streamer?os=android', video_id, data=b'')['data'] except ExtractorError as e: if not isinstance(e.cause, HTTPError): - raise e + raise errmsg = self._parse_json(e.cause.response.read().decode(), video_id)['meta']['message'] if 'country' in errmsg: self.raise_geo_restricted( diff --git a/yt_dlp/networking/_urllib.py b/yt_dlp/networking/_urllib.py index d3fe47ccc5..2929f75d0b 100644 --- a/yt_dlp/networking/_urllib.py +++ b/yt_dlp/networking/_urllib.py @@ -317,7 +317,7 @@ class UrllibResponseAdapter(Response): return data except Exception as e: handle_response_read_exceptions(e) - raise e + raise def handle_sslerror(e: ssl.SSLError):