mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 07:56:49 +00:00
[utils] Avoid comparing type(var)
, etc, to pass new Linter rules
This commit is contained in:
parent
abef53466d
commit
7d965e6b65
@ -727,7 +727,7 @@ class SWFInterpreter(object):
|
|||||||
stack.append(res)
|
stack.append(res)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assert isinstance(obj, (dict, _ScopeDict)),\
|
assert isinstance(obj, (dict, _ScopeDict)), \
|
||||||
'Accessing member %r on %r' % (pname, obj)
|
'Accessing member %r on %r' % (pname, obj)
|
||||||
res = obj.get(pname, undefined)
|
res = obj.get(pname, undefined)
|
||||||
stack.append(res)
|
stack.append(res)
|
||||||
|
@ -2235,7 +2235,7 @@ def _htmlentity_transform(entity_with_semicolon):
|
|||||||
def unescapeHTML(s):
|
def unescapeHTML(s):
|
||||||
if s is None:
|
if s is None:
|
||||||
return None
|
return None
|
||||||
assert type(s) == compat_str
|
assert isinstance(s, compat_str)
|
||||||
|
|
||||||
return re.sub(
|
return re.sub(
|
||||||
r'&([^&;]+;)', lambda m: _htmlentity_transform(m.group(1)), s)
|
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):
|
def write_string(s, out=None, encoding=None):
|
||||||
if out is None:
|
if out is None:
|
||||||
out = sys.stderr
|
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 sys.platform == 'win32' and encoding is None and hasattr(out, 'fileno'):
|
||||||
if _windows_write_string(s, out):
|
if _windows_write_string(s, out):
|
||||||
@ -4459,8 +4459,10 @@ TV_PARENTAL_GUIDELINES = {
|
|||||||
|
|
||||||
|
|
||||||
def parse_age_limit(s):
|
def parse_age_limit(s):
|
||||||
if type(s) == int:
|
if not isinstance(s, bool):
|
||||||
return s if 0 <= s <= 21 else None
|
age = int_or_none(s)
|
||||||
|
if age is not None:
|
||||||
|
return age if 0 <= age <= 21 else None
|
||||||
if not isinstance(s, compat_basestring):
|
if not isinstance(s, compat_basestring):
|
||||||
return None
|
return None
|
||||||
m = re.match(r'^(?P<age>\d{1,2})\+?$', s)
|
m = re.match(r'^(?P<age>\d{1,2})\+?$', s)
|
||||||
|
Loading…
Reference in New Issue
Block a user