diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2021-01-17 07:44:58 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-17 16:44:58 +0100 |
| commit | debda34e2d4f28d6d369cdafdcba4791702f63fc (patch) | |
| tree | 68799677bf5f81be5e32af24670277721adc5845 /pygments/formatters | |
| parent | 19d2096185de3282345eab1da611e56a26bcaec2 (diff) | |
| download | pygments-git-debda34e2d4f28d6d369cdafdcba4791702f63fc.tar.gz | |
Run pyupgrade across codebase to modernize syntax and patterns (#1622)
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 <Anteru@users.noreply.github.com>
Diffstat (limited to 'pygments/formatters')
| -rw-r--r-- | pygments/formatters/__init__.py | 3 | ||||
| -rwxr-xr-x | pygments/formatters/_mapping.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/bbcode.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/html.py | 3 | ||||
| -rw-r--r-- | pygments/formatters/img.py | 5 | ||||
| -rw-r--r-- | pygments/formatters/irc.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/latex.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/other.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/rtf.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/svg.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/terminal.py | 1 | ||||
| -rw-r--r-- | pygments/formatters/terminal256.py | 1 |
12 files changed, 4 insertions, 16 deletions
diff --git a/pygments/formatters/__init__.py b/pygments/formatters/__init__.py index e5e69303..66c9e9d4 100644 --- a/pygments/formatters/__init__.py +++ b/pygments/formatters/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters ~~~~~~~~~~~~~~~~~~~ @@ -107,7 +106,7 @@ def load_formatter_from_file(filename, formattername="CustomFormatter", formatter_class = custom_namespace[formattername] # And finally instantiate it with the options return formatter_class(**options) - except IOError as err: + except OSError as err: raise ClassNotFound('cannot read %s: %s' % (filename, err)) except ClassNotFound: raise diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py index 69657f9e..2592ef82 100755 --- a/pygments/formatters/_mapping.py +++ b/pygments/formatters/_mapping.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters._mapping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/bbcode.py b/pygments/formatters/bbcode.py index 99913583..586a8925 100644 --- a/pygments/formatters/bbcode.py +++ b/pygments/formatters/bbcode.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.bbcode ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py index 08aaa85f..7e903145 100644 --- a/pygments/formatters/html.py +++ b/pygments/formatters/html.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.html ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -628,7 +627,7 @@ class HtmlFormatter(Formatter): with open(cssfilename, "w") as cf: cf.write(CSSFILE_TEMPLATE % {'styledefs': self.get_style_defs('body')}) - except IOError as err: + except OSError as err: err.strerror = 'Error writing CSS file: ' + err.strerror raise diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py index 55687505..78176e14 100644 --- a/pygments/formatters/img.py +++ b/pygments/formatters/img.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.img ~~~~~~~~~~~~~~~~~~~~~~~ @@ -156,7 +155,7 @@ class FontManager: valname = '%s%s%s' % (basename, style and ' '+style, suffix) val, _ = _winreg.QueryValueEx(key, valname) return val - except EnvironmentError: + except OSError: continue else: if fail: @@ -190,7 +189,7 @@ class FontManager: lookuperror = err finally: _winreg.CloseKey(key) - except EnvironmentError: + except OSError: pass else: # If we get here, we checked all registry keys and had no luck diff --git a/pygments/formatters/irc.py b/pygments/formatters/irc.py index e4e59f2a..ab76fb83 100644 --- a/pygments/formatters/irc.py +++ b/pygments/formatters/irc.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.irc ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py index 6ebe935f..bd7ef9fa 100644 --- a/pygments/formatters/latex.py +++ b/pygments/formatters/latex.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.latex ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/other.py b/pygments/formatters/other.py index d7c6803c..16c2fceb 100644 --- a/pygments/formatters/other.py +++ b/pygments/formatters/other.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.other ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py index 890de2a2..ba071c78 100644 --- a/pygments/formatters/rtf.py +++ b/pygments/formatters/rtf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.rtf ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/svg.py b/pygments/formatters/svg.py index 1ec703ee..6950cd96 100644 --- a/pygments/formatters/svg.py +++ b/pygments/formatters/svg.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.svg ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py index 0499b6fa..cd4e2ce3 100644 --- a/pygments/formatters/terminal.py +++ b/pygments/formatters/terminal.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.terminal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/pygments/formatters/terminal256.py b/pygments/formatters/terminal256.py index c0c46476..0c318c5c 100644 --- a/pygments/formatters/terminal256.py +++ b/pygments/formatters/terminal256.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ pygments.formatters.terminal256 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
