From debda34e2d4f28d6d369cdafdcba4791702f63fc Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 17 Jan 2021 07:44:58 -0800 Subject: Run pyupgrade across codebase to modernize syntax and patterns (#1622) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pyupgrade is a tool to automatically upgrade syntax for newer versions of the Python language. The project has been Python 3 only since 35544e2fc6eed0ce4a27ec7285aac71ff0ddc473, allowing for several cleanups: - Remove unnecessary "-*- coding: utf-8 -*-" cookie. Python 3 reads all source files as utf-8 by default. - Replace IOError/EnvironmentError with OSError. Python 3 unified these exceptions. The old names are aliases only. - Use the Python 3 shorter super() syntax. - Remove "utf8" argument form encode/decode. In Python 3, this value is the default. - Remove "r" from open() calls. In Python 3, this value is the default. - Remove u prefix from Unicode strings. In Python 3, all strings are Unicode. - Replace io.open() with builtin open(). In Python 3, these functions are functionally equivalent. Co-authored-by: Matthäus G. Chajdas --- scripts/check_crlf.py | 1 - scripts/check_sources.py | 3 +-- scripts/debug_lexer.py | 1 - scripts/vim2pygments.py | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/check_crlf.py b/scripts/check_crlf.py index 880b496b..055446cf 100644 --- a/scripts/check_crlf.py +++ b/scripts/check_crlf.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """ Checker for line endings ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/scripts/check_sources.py b/scripts/check_sources.py index 21564415..2b79cfe6 100755 --- a/scripts/check_sources.py +++ b/scripts/check_sources.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """ Checker for file headers ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -188,7 +187,7 @@ def main(argv): try: with open(fn, 'rb') as f: lines = f.read().decode('utf-8').splitlines() - except (IOError, OSError) as err: + except OSError as err: print("%s: cannot open: %s" % (fn, err)) num += 1 continue diff --git a/scripts/debug_lexer.py b/scripts/debug_lexer.py index e173d344..a76265f5 100755 --- a/scripts/debug_lexer.py +++ b/scripts/debug_lexer.py @@ -1,5 +1,4 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- """ Lexing error finder ~~~~~~~~~~~~~~~~~~~ diff --git a/scripts/vim2pygments.py b/scripts/vim2pygments.py index 50d69bc6..2364e32a 100755 --- a/scripts/vim2pygments.py +++ b/scripts/vim2pygments.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """ Vim Colorscheme Converter ~~~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.1