From e95a563ed046eeca8942960be51d3feeaaf89c9c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Sat, 12 Nov 2022 00:41:26 +0530 Subject: [PATCH] Run `autopep8` This was run with `--aggressive --aggressive` and then false positives were discarded --- devscripts/buildserver.py | 3 ++- devscripts/gh-pages/update-feed.py | 3 +-- devscripts/make_issue_template.py | 1 + setup.py | 2 ++ youtube_dl/compat.py | 2 +- youtube_dl/utils.py | 10 ++++++---- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/devscripts/buildserver.py b/devscripts/buildserver.py index 4a4295ba9..96a565b4c 100644 --- a/devscripts/buildserver.py +++ b/devscripts/buildserver.py @@ -336,7 +336,7 @@ class YoutubeDLBuilder(object): try: proc = subprocess.Popen([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], stdin=subprocess.PIPE, cwd=self.buildPath) proc.wait() - #subprocess.check_output([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], + # subprocess.check_output([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], # cwd=self.buildPath) except subprocess.CalledProcessError as e: raise BuildError(e.output) @@ -429,5 +429,6 @@ class BuildHTTPRequestHandler(compat_http_server.BaseHTTPRequestHandler): else: self.send_response(500, 'Malformed URL') + if __name__ == '__main__': main() diff --git a/devscripts/gh-pages/update-feed.py b/devscripts/gh-pages/update-feed.py index 506a62377..635c2f6b9 100755 --- a/devscripts/gh-pages/update-feed.py +++ b/devscripts/gh-pages/update-feed.py @@ -40,8 +40,7 @@ now_iso = now.isoformat() + 'Z' atom_template = atom_template.replace('@TIMESTAMP@', now_iso) versions_info = json.load(open('update/versions.json')) -versions = list(versions_info['versions'].keys()) -versions.sort() +versions = sorted(versions_info['versions'].keys()) entries = [] for v in versions: diff --git a/devscripts/make_issue_template.py b/devscripts/make_issue_template.py index b7ad23d83..ce11b535a 100644 --- a/devscripts/make_issue_template.py +++ b/devscripts/make_issue_template.py @@ -25,5 +25,6 @@ def main(): with io.open(outfile, 'w', encoding='utf-8') as outf: outf.write(out) + if __name__ == '__main__': main() diff --git a/setup.py b/setup.py index af68b485e..7962af99e 100644 --- a/setup.py +++ b/setup.py @@ -83,6 +83,7 @@ else: else: params['scripts'] = ['bin/youtube-dl'] + class build_lazy_extractors(Command): description = 'Build the extractor lazy loading module' user_options = [] @@ -99,6 +100,7 @@ class build_lazy_extractors(Command): dry_run=self.dry_run, ) + setup( name='youtube_dl', version=__version__, diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index 28942a8c1..fb154414f 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -2684,7 +2684,7 @@ except (AssertionError, UnicodeEncodeError): def compat_ord(c): - if type(c) is int: + if isinstance(c, int): return c else: return ord(c) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index e3c3ccff9..6fe8098f0 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -2006,6 +2006,7 @@ def get_elements_by_attribute(attribute, value, html, escape_value=True): class HTMLAttributeParser(compat_HTMLParser): """Trivial HTML parser to gather the attributes for a single element""" + def __init__(self): self.attrs = {} compat_HTMLParser.__init__(self) @@ -2230,7 +2231,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) @@ -2262,7 +2263,7 @@ def encodeFilename(s, for_subprocess=False): @param s The name of the file """ - assert type(s) == compat_str + assert isinstance(s, compat_str) # Python 3 has a Unicode API if sys.version_info >= (3, 0): @@ -2431,6 +2432,7 @@ class GeoRestrictedError(ExtractorError): This exception may be thrown when a video is not available from your geographic location due to geographic restrictions imposed by a website. """ + def __init__(self, msg, countries=None): super(GeoRestrictedError, self).__init__(msg, expected=True) self.msg = msg @@ -3278,7 +3280,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): @@ -3456,7 +3458,7 @@ def unsmuggle_url(smug_url, default=None): def format_bytes(bytes): if bytes is None: return 'N/A' - if type(bytes) is str: + if isinstance(bytes, str): bytes = float(bytes) if bytes == 0.0: exponent = 0