diff options
author | Georg Brandl <georg@python.org> | 2020-01-04 16:18:43 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2020-01-04 16:18:43 +0100 |
commit | 5f4b1d0ffe1274f8632911e0edf183995f787e41 (patch) | |
tree | ab07daeacfbbf36ae9ef7aee285c708faf7d1d45 | |
parent | 58c34950dec138f4e3e52a56031b9a817fb54295 (diff) | |
download | pygments-git-5f4b1d0ffe1274f8632911e0edf183995f787e41.tar.gz |
Remove unneeded object inheritance.
-rw-r--r-- | pygments/filter.py | 2 | ||||
-rw-r--r-- | pygments/formatter.py | 2 | ||||
-rw-r--r-- | pygments/formatters/img.py | 2 | ||||
-rw-r--r-- | pygments/lexer.py | 9 | ||||
-rw-r--r-- | pygments/lexers/robotframework.py | 12 | ||||
-rw-r--r-- | pygments/lexers/sql.py | 4 | ||||
-rw-r--r-- | pygments/scanner.py | 2 | ||||
-rw-r--r-- | pygments/util.py | 2 | ||||
-rwxr-xr-x | scripts/vim2pygments.py | 2 | ||||
-rw-r--r-- | tests/test_basic_api.py | 2 | ||||
-rw-r--r-- | tests/test_util.py | 4 |
11 files changed, 22 insertions, 21 deletions
diff --git a/pygments/filter.py b/pygments/filter.py index 7f81920b..faa18bfc 100644 --- a/pygments/filter.py +++ b/pygments/filter.py @@ -40,7 +40,7 @@ def simplefilter(f): }) -class Filter(object): +class Filter: """ Default filter. Subclass this class or use the `simplefilter` decorator to create own filters. diff --git a/pygments/formatter.py b/pygments/formatter.py index efa90e51..60531523 100644 --- a/pygments/formatter.py +++ b/pygments/formatter.py @@ -23,7 +23,7 @@ def _lookup_style(style): return style -class Formatter(object): +class Formatter: """ Converts a token stream to text. diff --git a/pygments/formatters/img.py b/pygments/formatters/img.py index 5f0dcc56..57a37a7b 100644 --- a/pygments/formatters/img.py +++ b/pygments/formatters/img.py @@ -59,7 +59,7 @@ class FontNotFound(Exception): """When there are no usable fonts specified""" -class FontManager(object): +class FontManager: """ Manages a set of fonts: normal, italic, bold, etc... """ diff --git a/pygments/lexer.py b/pygments/lexer.py index 5614a7d4..9a0626c3 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -251,7 +251,7 @@ class include(str): # pylint: disable=invalid-name pass -class _inherit(object): +class _inherit: """ Indicates the a state should inherit from its superclass. """ @@ -274,7 +274,7 @@ class combined(tuple): # pylint: disable=invalid-name pass -class _PseudoMatch(object): +class _PseudoMatch: """ A pseudo match object constructed from a string. """ @@ -327,11 +327,12 @@ def bygroups(*args): return callback -class _This(object): +class _This: """ Special singleton used for indicating the caller class. Used by ``using``. """ + this = _This() @@ -674,7 +675,7 @@ class RegexLexer(Lexer, metaclass=RegexLexerMeta): break -class LexerContext(object): +class LexerContext: """ A helper object that holds lexer position data. """ diff --git a/pygments/lexers/robotframework.py b/pygments/lexers/robotframework.py index 284fdcf5..ddaddb22 100644 --- a/pygments/lexers/robotframework.py +++ b/pygments/lexers/robotframework.py @@ -83,7 +83,7 @@ class RobotFrameworkLexer(Lexer): index += len(value) -class VariableTokenizer(object): +class VariableTokenizer: def tokenize(self, string, token): var = VariableSplitter(string, identifiers='$@%&') @@ -110,7 +110,7 @@ class VariableTokenizer(object): yield value, token -class RowTokenizer(object): +class RowTokenizer: def __init__(self): self._table = UnknownTable() @@ -158,7 +158,7 @@ class RowTokenizer(object): yield value, token -class RowSplitter(object): +class RowSplitter: _space_splitter = re.compile('( {2,})') _pipe_splitter = re.compile(r'((?:^| +)\|(?: +|$))') @@ -184,7 +184,7 @@ class RowSplitter(object): yield rest -class Tokenizer(object): +class Tokenizer: _tokens = None def __init__(self): @@ -291,7 +291,7 @@ class KeywordCall(Tokenizer): return GherkinTokenizer().tokenize(value, KEYWORD) -class GherkinTokenizer(object): +class GherkinTokenizer: _gherkin_prefix = re.compile('^(Given|When|Then|And) ', re.IGNORECASE) def tokenize(self, value, token): @@ -319,7 +319,7 @@ class ForLoop(Tokenizer): return token -class _Table(object): +class _Table: _tokenizer_class = None def __init__(self, prev_tokenizer=None): diff --git a/pygments/lexers/sql.py b/pygments/lexers/sql.py index 1a53b0f6..0c45b14d 100644 --- a/pygments/lexers/sql.py +++ b/pygments/lexers/sql.py @@ -105,7 +105,7 @@ def language_callback(lexer, match): yield (match.start(7), String, match.group(7)) -class PostgresBase(object): +class PostgresBase: """Base class for Postgres-related lexers. This is implemented as a mixin to avoid the Lexer metaclass kicking in. @@ -270,7 +270,7 @@ re_message = re.compile( r'FATAL|HINT|DETAIL|CONTEXT|LINE [0-9]+):)(.*?\n)') -class lookahead(object): +class lookahead: """Wrap an iterator and allow pushing back an item.""" def __init__(self, x): self.iter = iter(x) diff --git a/pygments/scanner.py b/pygments/scanner.py index bcb19ed9..c7f9ab50 100644 --- a/pygments/scanner.py +++ b/pygments/scanner.py @@ -25,7 +25,7 @@ class EndOfText(RuntimeError): """ -class Scanner(object): +class Scanner: """ Simple scanner diff --git a/pygments/util.py b/pygments/util.py index fb81d464..bb88eb0c 100644 --- a/pygments/util.py +++ b/pygments/util.py @@ -289,7 +289,7 @@ def duplicates_removed(it, already_seen=()): return lst -class Future(object): +class Future: """Generic class to defer some work. Handled specially in RegexLexerMeta, to support regex string construction at diff --git a/scripts/vim2pygments.py b/scripts/vim2pygments.py index 42af0bbe..7012157c 100755 --- a/scripts/vim2pygments.py +++ b/scripts/vim2pygments.py @@ -863,7 +863,7 @@ def find_colors(code): return default_token, color_map -class StyleWriter(object): +class StyleWriter: def __init__(self, code, name): self.code = code diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index 583122d2..0bcb6989 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -254,7 +254,7 @@ def test_bare_class_handler(): assert False, 'nothing raised' -class TestFilters(object): +class TestFilters: def test_basic(self): filters_args = [ diff --git a/tests/test_util.py b/tests/test_util.py index d5706407..94985a25 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -14,7 +14,7 @@ from pytest import raises from pygments import util, console -class FakeLexer(object): +class FakeLexer: def analyse(text): return text analyse = util.make_analysator(analyse) @@ -81,7 +81,7 @@ def test_analysator_returns_boolean(): def test_analysator_raises_exception(): # If an analysator wrapped by make_analysator raises an exception, # then the wrapper will return 0.0. - class ErrorLexer(object): + class ErrorLexer: def analyse(text): raise RuntimeError('something bad happened') analyse = util.make_analysator(analyse) |