diff options
author | gbrandl <devnull@localhost> | 2007-01-25 23:42:16 +0100 |
---|---|---|
committer | gbrandl <devnull@localhost> | 2007-01-25 23:42:16 +0100 |
commit | e7ab63f9c55fe71d55386779127704166e313917 (patch) | |
tree | 0550c01a7cc769b75b4866a0c8a084e190d6c74e | |
parent | 80dfd874a2a42623537a20bdf0a7bd0a8b0e3849 (diff) | |
download | pygments-e7ab63f9c55fe71d55386779127704166e313917.tar.gz |
[svn] PyLint run.
-rw-r--r-- | pygments/__init__.py | 2 | ||||
-rw-r--r-- | pygments/filter.py | 1 | ||||
-rw-r--r-- | pygments/filters/__init__.py | 3 | ||||
-rw-r--r-- | pygments/formatters/terminal.py | 2 | ||||
-rw-r--r-- | pygments/lexers/text.py | 4 | ||||
-rw-r--r-- | pygments/plugin.py | 2 | ||||
-rw-r--r-- | pygments/styles/fruity.py | 2 | ||||
-rw-r--r-- | pygments/token.py | 8 | ||||
-rw-r--r-- | scripts/pylintrc | 162 |
9 files changed, 66 insertions, 120 deletions
diff --git a/pygments/__init__.py b/pygments/__init__.py index 1797ad90..c2dacb58 100644 --- a/pygments/__init__.py +++ b/pygments/__init__.py @@ -91,7 +91,7 @@ def highlight(code, lexer, formatter, outfile=None): def cmdline_main(args): """ Make pygments usable as a command line utility. - XXX: To be removed. + TODO: To be removed in Pygments 0.8. """ from pygments.cmdline import main return main(args) diff --git a/pygments/filter.py b/pygments/filter.py index d5e598ce..ef335eb3 100644 --- a/pygments/filter.py +++ b/pygments/filter.py @@ -60,6 +60,7 @@ class FunctionFilter(Filter): automatically creates subclasses of this class for functions passed to it. """ + function = None def __init__(self, **options): if not hasattr(self, 'function'): diff --git a/pygments/filters/__init__.py b/pygments/filters/__init__.py index be52a01b..135e9a04 100644 --- a/pygments/filters/__init__.py +++ b/pygments/filters/__init__.py @@ -52,7 +52,7 @@ class CodeTagFilter(Filter): words. """ def __init__(self, **options): - Filter.__init__(self) + Filter.__init__(self, **options) tags = get_list_opt(options, 'codetags', ['XXX', 'TODO', 'BUG', 'NOTE']) self.tag_re = re.compile(r'(%s)' % '|'.join([ @@ -116,6 +116,7 @@ class NameHighlightFilter(Filter): """ def __init__(self, **options): + Filter.__init__(self, **options) self.words = set(get_list_opt(options, 'highlight', [])) highlight_token = options.get('highlight_token') if highlight_token: diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py index 6ac6cd1b..4c6d2f9f 100644 --- a/pygments/formatters/terminal.py +++ b/pygments/formatters/terminal.py @@ -9,8 +9,6 @@ :license: BSD, see LICENSE for more details. """ -import os - from pygments.formatter import Formatter from pygments.token import Keyword, Name, Comment, String, Error, \ Number, Operator, Generic, Token diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py index 126e554b..8e33e446 100644 --- a/pygments/lexers/text.py +++ b/pygments/lexers/text.py @@ -18,7 +18,7 @@ try: except NameError: from sets import Set as set -from pygments.lexer import Lexer, RegexLexer, bygroups, include, using, this +from pygments.lexer import RegexLexer, bygroups, include, using, this from pygments.token import Punctuation, \ Text, Comment, Keyword, Name, String, Generic, Operator, Number @@ -62,7 +62,7 @@ class SourcesListLexer(RegexLexer): *New in Pygments 0.7.* """ - name= 'Debian Sourcelist' + name = 'Debian Sourcelist' aliases = ['sourceslist', 'sources.list'] filenames = ['sources.list'] mimetype = ['application/x-debian-sourceslist'] diff --git a/pygments/plugin.py b/pygments/plugin.py index 89300677..5e09c123 100644 --- a/pygments/plugin.py +++ b/pygments/plugin.py @@ -68,7 +68,7 @@ def find_plugin_styles(): def find_plugin_filters(): - if pkg_recources is None: + if pkg_resources is None: return for entrypoint in pkg_resources.iter_entry_points(FILTER_ENTRY_POINT): yield entrypoint.name, entrypoint.load() diff --git a/pygments/styles/fruity.py b/pygments/styles/fruity.py index a6da42bb..1827b2df 100644 --- a/pygments/styles/fruity.py +++ b/pygments/styles/fruity.py @@ -11,7 +11,7 @@ from pygments.style import Style from pygments.token import Token, Comment, Name, Keyword, \ - Generic, Number, Operator, String + Generic, Number, String class FruityStyle(Style): diff --git a/pygments/token.py b/pygments/token.py index 53a59ba6..fce94303 100644 --- a/pygments/token.py +++ b/pygments/token.py @@ -204,12 +204,12 @@ STANDARD_TYPES = { if __name__ == '__main__': import sys # sanity check for token name dict: no duplicate entries! - s = STANDARD_TYPES.copy() - s[Token] = '---' # Token and Text do conflict, that is okay + stp = STANDARD_TYPES.copy() + stp[Token] = '---' # Token and Text do conflict, that is okay t = {} - for k, v in s.iteritems(): + for k, v in stp.iteritems(): t.setdefault(v, []).append(k) - if len(t) == len(s): + if len(t) == len(stp): print 'Okay!' sys.exit() diff --git a/scripts/pylintrc b/scripts/pylintrc index 94e5ea00..aa04e12e 100644 --- a/scripts/pylintrc +++ b/scripts/pylintrc @@ -6,13 +6,11 @@ # * handle message activation / deactivation at the module level # * handle some basic but necessary stats'data (number of classes, methods...) # -# This checker also defines the following reports: -# * R0001: Total errors / warnings -# * R0002: % errors / warnings by module -# * R0003: Messages -# * R0004: Global evaluation [MASTER] +# Specify a configuration file. +#rcfile= + # Profiled execution. profile=no @@ -31,26 +29,46 @@ cache-size=500 load-plugins= -[REPORTS] +[MESSAGES CONTROL] + +# Enable only checker(s) with the given id(s). This option conflict with the +# disable-checker option +#enable-checker= + +# Enable all checker(s) except those with the given id(s). This option conflict +# with the disable-checker option +#disable-checker= + +# Enable all messages in the listed categories. +#enable-msg-cat= + +# Disable all messages in the listed categories. +#disable-msg-cat= + +# Enable the message(s) with the given id(s). +#enable-msg= + +# Disable the message(s) with the given id(s). +disable-msg=C0323,W0142,C0301,C0103,C0111,E0213,C0302,C0203,W0703,R0201 -# Tells wether to display a full report or only the messages -reports=no -# Use HTML as output format instead of text -html=no +[REPORTS] -# Use a parseable text output format, so your favorite text editor will be able -# to jump to the line corresponding to a message. -parseable=no +# set the output format. Available formats are text, parseable, colorized and +# html +output-format=colorized -# Colorizes text output using ansi escape codes -color=yes +# Include message's id in output +include-ids=yes # Put messages in a separate file for each module / package specified on the # command line instead of printing them on stdout. Reports (if any) will be # written in a file name "pylint_global.[txt|html]". files-output=no +# Tells wether to display a full report or only the messages +reports=yes + # Python expression which should return a note less than 10 (10 is the highest # note).You have access to the variables errors warning, statement which # respectivly contain the number of errors / warnings messages and the total @@ -62,11 +80,11 @@ evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / stateme # evaluation report (R0004). comment=no -# Include message's id in output -include-ids=no +# Enable the report(s) with the given id(s). +#enable-report= -# Disable some irrelevant messages. -disable-msg=W0142,W0613,R0201,W0704,C0111,W0703,W0603,I0011,W0122,C0321,W0631,C0203,W0511,W0221,R0401 +# Disable the report(s) with the given id(s). +#disable-report= # checks for @@ -77,9 +95,6 @@ disable-msg=W0142,W0613,R0201,W0704,C0111,W0703,W0603,I0011,W0122,C0321,W0631,C0 # [VARIABLES] -# Enable / disable this checker -enable-variables=yes - # Tells wether we should check for unused import in __init__ files. init-import=no @@ -95,20 +110,17 @@ additional-builtins= # [TYPECHECK] -# Enable / disable this checker -enable-typecheck=yes - # Tells wether missing members accessed in mixin class should be ignored. A # mixin class is detected if its name ends with "mixin" (case insensitive). ignore-mixin-members=yes # When zope mode is activated, consider the acquired-members option to ignore # access to some undefined attributes. -zope=yes +zope=no # List of members which are usually get through zope's acquisition mecanism and # so shouldn't trigger E0201 when accessed (need zope=yes to be considered). -acquired-members=__subclasses__,__dict__ +acquired-members=REQUEST,acl_users,aq_parent # checks for : @@ -121,16 +133,10 @@ acquired-members=__subclasses__,__dict__ # * redefinition of function / method / class # * uses of the global statement # -# This checker also defines the following reports: -# * R0101: Statistics by type [BASIC] -# Enable / disable this checker -enable-basic=yes - # Required attributes for module, separated by a comma required-attributes= -#__revision__ # Regular expression which should only match functions or classes name which do # not require a docstring @@ -140,25 +146,25 @@ no-docstring-rgx=__.*__ module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ # Regular expression which should only match correct module level names -const-rgx=(([A-Z_][A-Z1-9_]*)|[A-Za-z_][a-z1-9_]*|(__.*__))$ +const-rgx=(([A-Z_][A-Z1-9_]*)|(__.*__))$ # Regular expression which should only match correct class names -class-rgx=([A-Z_][a-zA-Z0-9]+|[a-z_]+|__metaclass__)$ +class-rgx=[A-Z_][a-zA-Z0-9]+$ # Regular expression which should only match correct function names -function-rgx=[a-z_][a-z0-9_]{1,30}$ +function-rgx=[a-z_][a-z0-9_]{2,30}$ # Regular expression which should only match correct method names -method-rgx=[a-z_][a-z0-9_]{1,30}$ +method-rgx=[a-z_][a-z0-9_]{2,30}$ # Regular expression which should only match correct instance attribute names -attr-rgx=[a-z_][a-z0-9_]{0,30}$ +attr-rgx=[a-z_][a-z0-9_]{2,30}$ # Regular expression which should only match correct argument names -argument-rgx=[a-z_][a-z0-9_]{0,30}$ +argument-rgx=[a-z_][a-z0-9_]{2,30}$ # Regular expression which should only match correct variable names -variable-rgx=[a-z_][a-z0-9_]{0,30}$ +variable-rgx=[a-z_][a-z0-9_]{2,30}$ # Regular expression which should only match correct list comprehension / # generator expression variable names @@ -180,9 +186,6 @@ bad-functions=apply,input # [DESIGN] -# Enable / disable this checker -enable-design=yes - # Maximum number of arguments for function / method max-args=12 @@ -190,37 +193,25 @@ max-args=12 max-locals=30 # Maximum number of return / yield for function / method body -max-returns=15 +max-returns=12 # Maximum number of branch for function / method body -max-branchs=50 +max-branchs=30 # Maximum number of statements in function / method body -max-statements=120 +max-statements=60 # Maximum number of parents for a class (see R0901). max-parents=7 # Maximum number of attributes for a class (see R0902). -max-attributes=25 +max-attributes=20 # Minimum number of public methods for a class (see R0903). min-public-methods=0 # Maximum number of public methods for a class (see R0904). -max-public-methods=30 - - -# checks for usage of new style capabilities on old style classes and -# other new/old styles conflicts problems -# * use of property, __slots__, super -# * "super" usage -# * raising a new style class as exception -# -[NEWSTYLE] - -# Enable / disable this checker -enable-newstyle=yes +max-public-methods=20 # checks for @@ -229,14 +220,8 @@ enable-newstyle=yes # * cyclic imports # * uses of deprecated modules # -# This checker also defines the following reports: -# * R0401: External dependencies -# * R0402: Modules dependencies graph [IMPORTS] -# Enable / disable this checker -enable-imports=yes - # Deprecated modules which should not be used, separated by a comma deprecated-modules=regsub,string,TERMIOS,Bastion,rexec @@ -255,7 +240,7 @@ int-import-graph= # checks for : # * methods without self as first argument -# * overriden methods signature +# * overridden methods signature # * access only to existant members via self # * attributes not defined in the __init__ method # * supported interfaces implementation @@ -263,9 +248,6 @@ int-import-graph= # [CLASSES] -# Enable / disable this checker -enable-classes=yes - # List of interface methods to ignore, separated by a comma. This is used for # instance to not check methods defines in Zope's Interface base class. ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by @@ -274,42 +256,12 @@ ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions defining-attr-methods=__init__,__new__,setUp -# checks for -# * excepts without exception filter -# * string exceptions -# -[EXCEPTIONS] - -# Enable / disable this checker -enable-exceptions=yes - - -# does not check anything but gives some raw metrics : -# * total number of lines -# * total number of code lines -# * total number of docstring lines -# * total number of comments lines -# * total number of empty lines -# -# This checker also defines the following reports: -# * R0701: Raw metrics -[METRICS] - -# Enable / disable this checker -enable-metrics=yes - - # checks for similarities and duplicated code. This computation may be # memory / CPU intensive, so you should disable it if you experiments some # problems. # -# This checker also defines the following reports: -# * R0801: Duplication [SIMILARITIES] -# Enable / disable this checker -enable-similarities=yes - # Minimum lines number of a similarity. min-similarity-lines=10 @@ -321,16 +273,13 @@ ignore-docstrings=yes # checks for: -# * warning notes in the code +# * warning notes in the code like FIXME, XXX # * PEP 263: source code with non ascii character but no encoding declaration # [MISCELLANEOUS] -# Enable / disable this checker -enable-miscellaneous=yes - # List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO,HACK +notes=FIXME,XXX,TODO # checks for : @@ -341,9 +290,6 @@ notes=FIXME,XXX,TODO,HACK # [FORMAT] -# Enable / disable this checker -enable-format=yes - # Maximum number of characters on a single line. max-line-length=90 |