A feature-rich command-line audio/video downloader
[cleanup] Bump ruff to 0.5.x (#10282)
sepro7814c50948a2
diff --git a/pyproject.toml b/pyproject.tomlindex 01162b794c..a2442a14d5 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -72,7 +72,7 @@ dev = []static-analysis = ["autopep8~=2.0",- "ruff~=0.4.4",+ "ruff~=0.5.0",]test = ["pytest~=8.1",@@ -211,6 +211,7 @@ ignore = ["TD002", # missing-todo-author"TD003", # missing-todo-link"PLE0604", # invalid-all-object (false positives)+ "PLE0643", # potential-index-error (false positives)"PLW0603", # global-statement"PLW1510", # subprocess-run-without-check"PLW2901", # redefined-loop-namediff --git a/yt_dlp/extractor/atresplayer.py b/yt_dlp/extractor/atresplayer.pyindex 7c8139714f..0fe95bec5c 100644--- a/yt_dlp/extractor/atresplayer.py+++ b/yt_dlp/extractor/atresplayer.py@@ -33,14 +33,6 @@ class AtresPlayerIE(InfoExtractor):]_API_BASE = 'https://api.atresplayer.com/'- def _handle_error(self, e, code):- if isinstance(e.cause, HTTPError) and e.cause.status == code:- error = self._parse_json(e.cause.response.read(), None)- if error.get('error') == 'required_registered':- self.raise_login_required()- raise ExtractorError(error['error_description'], expected=True)- raise-def _perform_login(self, username, password):self._request_webpage(self._API_BASE + 'login', None, 'Downloading login page')@@ -55,7 +47,9 @@ class AtresPlayerIE(InfoExtractor):'password': password,}))['targetUrl']except ExtractorError as e:- self._handle_error(e, 400)+ if isinstance(e.cause, HTTPError) and e.cause.status == 400:+ raise ExtractorError('Invalid username and/or password', expected=True)+ raiseself._request_webpage(target_url, None, 'Following Target URL')@@ -66,7 +60,12 @@ class AtresPlayerIE(InfoExtractor):episode = self._download_json(self._API_BASE + 'client/v1/player/episode/' + video_id, video_id)except ExtractorError as e:- self._handle_error(e, 403)+ if isinstance(e.cause, HTTPError) and e.cause.status == 403:+ error = self._parse_json(e.cause.response.read(), None)+ if error.get('error') == 'required_registered':+ self.raise_login_required()+ raise ExtractorError(error['error_description'], expected=True)+ raisetitle = episode['titulo']diff --git a/yt_dlp/extractor/cbc.py b/yt_dlp/extractor/cbc.pyindex 740e129264..1522b08e25 100644--- a/yt_dlp/extractor/cbc.py+++ b/yt_dlp/extractor/cbc.py@@ -455,10 +455,8 @@ class CBCGemIE(InfoExtractor):def claims_token_expired(self):exp = self._get_claims_token_expiry()- if exp - time.time() < 10:- # It will expire in less than 10 seconds, or has already expired- return True- return False+ # It will expire in less than 10 seconds, or has already expired+ return exp - time.time() < 10def claims_token_valid(self):return self._claims_token is not None and not self.claims_token_expired()diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.pyindex 5c82de19ea..a0f32892fd 100644--- a/yt_dlp/jsinterp.py+++ b/yt_dlp/jsinterp.py@@ -667,12 +667,12 @@ class JSInterpreter:self.interpret_expression(v, local_vars, allow_recursion)for v in self._separate(arg_str)]- if obj == str:+ if obj is str:if member == 'fromCharCode':assertion(argvals, 'takes one or more arguments')return ''.join(map(chr, argvals))raise self.Exception(f'Unsupported String method {member}', expr)- elif obj == float:+ elif obj is float:if member == 'pow':assertion(len(argvals) == 2, 'takes two arguments')return argvals[0] ** argvals[1]diff --git a/yt_dlp/networking/_requests.py b/yt_dlp/networking/_requests.pyindex c69c54b3a0..86850c1851 100644--- a/yt_dlp/networking/_requests.py+++ b/yt_dlp/networking/_requests.py@@ -230,9 +230,7 @@ class Urllib3LoggingFilter(logging.Filter):def filter(self, record):# Ignore HTTP request messages since HTTPConnection prints those- if record.msg == '%s://%s:%s "%s %s %s" %s %s':- return False- return True+ return record.msg != '%s://%s:%s "%s %s %s" %s %s'class Urllib3LoggingHandler(logging.Handler):