summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2015-10-14 12:08:43 -0700
committerTim Hatch <tim@timhatch.com>2015-10-14 12:08:43 -0700
commit96990f584f1e14c9c68b96c967b9f31f34ef33bb (patch)
tree25c9760b29e56e186d91766d6803c324c313db93
parent697b7a780f5b3312bc27728a095c6eecd4907d5b (diff)
downloadpygments-96990f584f1e14c9c68b96c967b9f31f34ef33bb.tar.gz
Fixes noted by pylint, mostly.
-rw-r--r--pygments/__init__.py6
-rw-r--r--pygments/cmdline.py11
-rw-r--r--pygments/filter.py2
-rw-r--r--pygments/lexer.py16
-rw-r--r--pygments/lexers/roboconf.py2
-rw-r--r--pygments/lexers/tap.py2
-rw-r--r--pygments/util.py4
7 files changed, 22 insertions, 21 deletions
diff --git a/pygments/__init__.py b/pygments/__init__.py
index 1ce34b2a..b37bdccb 100644
--- a/pygments/__init__.py
+++ b/pygments/__init__.py
@@ -46,13 +46,13 @@ def lex(code, lexer):
except TypeError as err:
if isinstance(err.args[0], str) and \
('unbound method get_tokens' in err.args[0] or
- 'missing 1 required positional argument' in err.args[0]):
+ 'missing 1 required positional argument' in err.args[0]):
raise TypeError('lex() argument must be a lexer instance, '
'not a class')
raise
-def format(tokens, formatter, outfile=None):
+def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builtin
"""
Format a tokenlist ``tokens`` with the formatter ``formatter``.
@@ -70,7 +70,7 @@ def format(tokens, formatter, outfile=None):
except TypeError as err:
if isinstance(err.args[0], str) and \
('unbound method format' in err.args[0] or
- 'missing 1 required positional argument' in err.args[0]):
+ 'missing 1 required positional argument' in err.args[0]):
raise TypeError('format() argument must be a formatter instance, '
'not a class')
raise
diff --git a/pygments/cmdline.py b/pygments/cmdline.py
index f5ea5653..00745edc 100644
--- a/pygments/cmdline.py
+++ b/pygments/cmdline.py
@@ -19,11 +19,12 @@ from pygments import __version__, highlight
from pygments.util import ClassNotFound, OptionError, docstring_headline, \
guess_decode, guess_decode_from_terminal, terminal_encoding
from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
- get_lexer_for_filename, find_lexer_class_for_filename, TextLexer
+ get_lexer_for_filename, find_lexer_class_for_filename
+from pygments.lexers.special import TextLexer
from pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
from pygments.formatters import get_all_formatters, get_formatter_by_name, \
- get_formatter_for_filename, find_formatter_class, \
- TerminalFormatter # pylint:disable-msg=E0611
+ get_formatter_for_filename, find_formatter_class
+from pygments.formatters.terminal import TerminalFormatter
from pygments.filters import get_all_filters, find_filter_class
from pygments.styles import get_all_styles, get_style_by_name
@@ -247,7 +248,7 @@ def main_inner(popts, args, usage):
print(usage, file=sys.stderr)
return 2
- what, name = args
+ what, name = args # pylint: disable=unbalanced-tuple-unpacking
if what not in ('lexer', 'formatter', 'filter'):
print(usage, file=sys.stderr)
return 2
@@ -269,7 +270,7 @@ def main_inner(popts, args, usage):
opts.pop('-P', None)
# encodings
- inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
+ inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
outencoding = parsed_opts.get('outencoding', parsed_opts.get('encoding'))
# handle ``pygmentize -N``
diff --git a/pygments/filter.py b/pygments/filter.py
index 529d4f54..c8176ed9 100644
--- a/pygments/filter.py
+++ b/pygments/filter.py
@@ -69,6 +69,6 @@ class FunctionFilter(Filter):
Filter.__init__(self, **options)
def filter(self, lexer, stream):
- # pylint: disable-msg=E1102
+ # pylint: disable=not-callable
for ttype, value in self.function(lexer, stream, self.options):
yield ttype, value
diff --git a/pygments/lexer.py b/pygments/lexer.py
index 581508b0..e846890e 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -42,10 +42,10 @@ class LexerMeta(type):
static methods which always return float values.
"""
- def __new__(cls, name, bases, d):
+ def __new__(mcs, name, bases, d):
if 'analyse_text' in d:
d['analyse_text'] = make_analysator(d['analyse_text'])
- return type.__new__(cls, name, bases, d)
+ return type.__new__(mcs, name, bases, d)
@add_metaclass(LexerMeta)
@@ -188,7 +188,7 @@ class Lexer(object):
text += '\n'
def streamer():
- for i, t, v in self.get_tokens_unprocessed(text):
+ for _, t, v in self.get_tokens_unprocessed(text):
yield t, v
stream = streamer()
if not unfiltered:
@@ -245,7 +245,7 @@ class DelegatingLexer(Lexer):
#
-class include(str):
+class include(str): # pylint: disable=invalid-name
"""
Indicates that a state should include rules from another state.
"""
@@ -259,10 +259,10 @@ class _inherit(object):
def __repr__(self):
return 'inherit'
-inherit = _inherit()
+inherit = _inherit() # pylint: disable=invalid-name
-class combined(tuple):
+class combined(tuple): # pylint: disable=invalid-name
"""
Indicates a state combined from multiple states.
"""
@@ -319,8 +319,8 @@ def bygroups(*args):
if data is not None:
if ctx:
ctx.pos = match.start(i + 1)
- for item in action(lexer, _PseudoMatch(match.start(i + 1),
- data), ctx):
+ for item in action(
+ lexer, _PseudoMatch(match.start(i + 1), data), ctx):
if item:
yield item
if ctx:
diff --git a/pygments/lexers/roboconf.py b/pygments/lexers/roboconf.py
index f350ea6b..cbddd9e8 100644
--- a/pygments/lexers/roboconf.py
+++ b/pygments/lexers/roboconf.py
@@ -10,7 +10,7 @@
"""
from pygments.lexer import RegexLexer, words, bygroups, re, include
-from pygments.token import *
+from pygments.token import Text, Operator, Keyword, Name, Comment
__all__ = ['RoboconfGraphLexer', 'RoboconfInstancesLexer']
diff --git a/pygments/lexers/tap.py b/pygments/lexers/tap.py
index 7d965c80..777dfdf0 100644
--- a/pygments/lexers/tap.py
+++ b/pygments/lexers/tap.py
@@ -5,7 +5,7 @@
Lexer for the Test Anything Protocol (TAP).
- :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/pygments/util.py b/pygments/util.py
index c464e17c..0859c05d 100644
--- a/pygments/util.py
+++ b/pygments/util.py
@@ -122,7 +122,7 @@ def make_analysator(f):
def shebang_matches(text, regex):
- """Check if the given regular expression matches the last part of the
+ r"""Check if the given regular expression matches the last part of the
shebang if one exists.
>>> from pygments.util import shebang_matches
@@ -160,7 +160,7 @@ def shebang_matches(text, regex):
if x and not x.startswith('-')][-1]
except IndexError:
return False
- regex = re.compile('^%s(\.(exe|cmd|bat|bin))?$' % regex, re.IGNORECASE)
+ regex = re.compile(r'^%s(\.(exe|cmd|bat|bin))?$' % regex, re.IGNORECASE)
if regex.search(found) is not None:
return True
return False