aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2023-07-30 21:45:57 +0100
committerdirkf <fieldhouse@gmx.net>2023-08-01 01:05:09 +0100
commit7d965e6b65655f2a5fbae34219fc87359a3d7061 (patch)
tree51f8658c2f8b2704c612a3e3ddcffcdb07431dff
parentabef53466da1f7d2e79f5644718a2cf7524abc49 (diff)
[utils] Avoid comparing `type(var)`, etc, to pass new Linter rules
-rw-r--r--youtube_dl/swfinterp.py2
-rw-r--r--youtube_dl/utils.py10
2 files changed, 7 insertions, 5 deletions
diff --git a/youtube_dl/swfinterp.py b/youtube_dl/swfinterp.py
index 0c7158575..e79e0b17f 100644
--- a/youtube_dl/swfinterp.py
+++ b/youtube_dl/swfinterp.py
@@ -727,7 +727,7 @@ class SWFInterpreter(object):
stack.append(res)
continue
- assert isinstance(obj, (dict, _ScopeDict)),\
+ assert isinstance(obj, (dict, _ScopeDict)), \
'Accessing member %r on %r' % (pname, obj)
res = obj.get(pname, undefined)
stack.append(res)
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 36204c8fa..1da5a7a38 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -2235,7 +2235,7 @@ def _htmlentity_transform(entity_with_semicolon):
def unescapeHTML(s):
if s is None:
return None
- assert type(s) == compat_str
+ assert isinstance(s, compat_str)
return re.sub(
r'&([^&;]+;)', lambda m: _htmlentity_transform(m.group(1)), s)
@@ -3418,7 +3418,7 @@ def _windows_write_string(s, out):
def write_string(s, out=None, encoding=None):
if out is None:
out = sys.stderr
- assert type(s) == compat_str
+ assert isinstance(s, compat_str)
if sys.platform == 'win32' and encoding is None and hasattr(out, 'fileno'):
if _windows_write_string(s, out):
@@ -4459,8 +4459,10 @@ TV_PARENTAL_GUIDELINES = {
def parse_age_limit(s):
- if type(s) == int:
- return s if 0 <= s <= 21 else None
+ if not isinstance(s, bool):
+ age = int_or_none(s)
+ if age is not None:
+ return age if 0 <= age <= 21 else None
if not isinstance(s, compat_basestring):
return None
m = re.match(r'^(?P<age>\d{1,2})\+?$', s)