[javascriptlint-commit] SF.net SVN: javascriptlint:[327] trunk
Status: Beta
Brought to you by:
matthiasmiller
|
From: <mat...@us...> - 2013-10-02 23:18:33
|
Revision: 327
http://sourceforge.net/p/javascriptlint/code/327
Author: matthiasmiller
Date: 2013-10-02 23:18:30 +0000 (Wed, 02 Oct 2013)
Log Message:
-----------
pylint: fix raise syntax
Modified Paths:
--------------
trunk/javascriptlint/conf.py
trunk/javascriptlint/visitation.py
trunk/javascriptlint/warnings.py
trunk/setup.py
trunk/test.py
trunk/www.py
Modified: trunk/javascriptlint/conf.py
===================================================================
--- trunk/javascriptlint/conf.py 2013-10-02 23:16:54 UTC (rev 326)
+++ trunk/javascriptlint/conf.py 2013-10-02 23:18:30 UTC (rev 327)
@@ -119,7 +119,7 @@
wants_parm = False
value = None
def load(self, enabled):
- raise ConfError, 'This setting is deprecated.'
+ raise ConfError('This setting is deprecated.')
class BooleanSetting(Setting):
wants_parm = False
@@ -134,7 +134,7 @@
self.value = default
def load(self, enabled, parm):
if not enabled:
- raise ConfError, 'Expected +.'
+ raise ConfError('Expected +.')
self.value = parm
class DeclareSetting(Setting):
@@ -143,7 +143,7 @@
self.value = []
def load(self, enabled, parm):
if not enabled:
- raise ConfError, 'Expected +.'
+ raise ConfError('Expected +.')
self.value.append(parm)
class ProcessSetting(Setting):
@@ -162,11 +162,11 @@
value = util.JSVersion.default()
def load(self, enabled, parm):
if not enabled:
- raise ConfError, 'Expected +.'
+ raise ConfError('Expected +.')
self.value = util.JSVersion.fromtype(parm)
if not self.value:
- raise ConfError, 'Invalid JavaScript version: %s' % parm
+ raise ConfError('Invalid JavaScript version: %s' % parm)
class Conf:
def __init__(self):
@@ -227,7 +227,7 @@
elif line.startswith('-'):
enabled = False
else:
- raise ConfError, 'Expected + or -.'
+ raise ConfError('Expected + or -.')
line = line[1:]
# Parse the key/parms
@@ -242,7 +242,7 @@
if setting.wants_parm:
args['parm'] = parm
elif parm:
- raise ConfError, 'The %s setting does not expect a parameter.' % name
+ raise ConfError('The %s setting does not expect a parameter.' % name)
if setting.wants_dir:
args['dir'] = dir
setting.load(**args)
Modified: trunk/javascriptlint/visitation.py
===================================================================
--- trunk/javascriptlint/visitation.py 2013-10-02 23:16:54 UTC (rev 326)
+++ trunk/javascriptlint/visitation.py 2013-10-02 23:18:30 UTC (rev 327)
@@ -27,9 +27,9 @@
# Intantiate an instance of each class
for klass in klasses:
if klass.__name__.lower() != klass.__name__:
- raise ValueError, 'class names must be lowercase'
+ raise ValueError('class names must be lowercase')
if not klass.__doc__:
- raise ValueError, 'missing docstring on class %s' % klass.__name__
+ raise ValueError('missing docstring on class %s' % klass.__name__)
# Look for functions with the "_visit_nodes" property.
visitor = klass()
Modified: trunk/javascriptlint/warnings.py
===================================================================
--- trunk/javascriptlint/warnings.py 2013-10-02 23:16:54 UTC (rev 326)
+++ trunk/javascriptlint/warnings.py 2013-10-02 23:18:30 UTC (rev 327)
@@ -12,7 +12,7 @@
@lookfor(tok.NODEKIND, (tok.NODEKIND, op.OPCODE))
def warning_name(node):
if questionable:
- raise LintWarning, node
+ raise LintWarning(node)
"""
import itertools
import re
@@ -125,7 +125,7 @@
try:
errdesc = re.sub(r"{(\w+)}", lambda match: errargs[match.group(1)], errdesc)
except (TypeError, KeyError):
- raise KeyError, 'Invalid keyword in error: ' + errdesc
+ raise KeyError('Invalid keyword in error: ' + errdesc)
return errdesc
_visitors = []
@@ -253,17 +253,17 @@
def comparison_type_conv(node):
for kid in node.kids:
if kid.kind == tok.PRIMARY and kid.opcode in (op.NULL, op.TRUE, op.FALSE):
- raise LintWarning, kid
+ raise LintWarning(kid)
if kid.kind == tok.NUMBER and not kid.dval:
- raise LintWarning, kid
+ raise LintWarning(kid)
if kid.kind == tok.STRING and not kid.atom:
- raise LintWarning, kid
+ raise LintWarning(kid)
@lookfor(tok.DEFAULT)
def default_not_at_end(node):
siblings = node.parent.kids
if node.node_index != len(siblings)-1:
- raise LintWarning, siblings[node.node_index+1]
+ raise LintWarning(siblings[node.node_index+1])
@lookfor(tok.CASE)
def duplicate_case_in_switch(node):
@@ -276,7 +276,7 @@
if sibling.kind == tok.CASE:
sibling_value = sibling.kids[0]
if node_value.is_equivalent(sibling_value, True):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.SWITCH)
def missing_default_case(node):
@@ -284,21 +284,21 @@
for case in cases.kids:
if case.kind == tok.DEFAULT:
return
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.WITH)
def with_statement(node):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.EQOP,tok.RELOP)
def useless_comparison(node):
for lvalue, rvalue in itertools.combinations(node.kids, 2):
if lvalue.is_equivalent(rvalue):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor((tok.COLON, op.NAME))
def use_of_label(node):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor((tok.OBJECT, op.REGEXP))
def misplaced_regex(node):
@@ -314,7 +314,7 @@
return # Allow in /re/.property
if node.parent.kind == tok.RETURN:
return # Allow for return values
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.ASSIGN)
def assign_to_function_call(node):
@@ -323,7 +323,7 @@
while kid.kind == tok.RP:
kid, = kid.kids
if kid.kind == tok.LP:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor((tok.ASSIGN, None))
def equal_as_assign(node):
@@ -333,7 +333,7 @@
if not node.parent.kind in (tok.SEMI, tok.RESERVED, tok.RP, tok.COMMA,
tok.ASSIGN):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.IF)
def ambiguous_else_stmt(node):
@@ -349,13 +349,13 @@
return
# Else is only ambiguous in the first branch of an if statement.
if tmp.parent.kind == tok.IF and tmp.node_index == 1:
- raise LintWarning, else_
+ raise LintWarning(else_)
tmp = tmp.parent
@lookfor(tok.IF, tok.WHILE, tok.DO, tok.FOR, tok.WITH)
def block_without_braces(node):
if node.kids[1].kind != tok.LC:
- raise LintWarning, node.kids[1]
+ raise LintWarning(node.kids[1])
_block_nodes = (tok.IF, tok.WHILE, tok.DO, tok.FOR, tok.WITH)
@lookfor(*_block_nodes)
@@ -368,7 +368,7 @@
# was inside a block statement without clarifying curlies.
# (Otherwise, the node type would be tok.LC.)
if node.parent.kind in _block_nodes:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.INC, tok.DEC)
def inc_dec_within_stmt(node):
@@ -384,7 +384,7 @@
tmp.parent.parent.kind == tok.FOR:
return
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.COMMA)
def comma_separated_stmts(node):
@@ -394,12 +394,12 @@
# This is an array
if node.parent.kind == tok.RB:
return
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.SEMI)
def empty_statement(node):
if not node.kids[0]:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.LC)
def empty_statement_(node):
if node.kids:
@@ -410,7 +410,7 @@
# Some empty blocks are meaningful.
if node.parent.kind in (tok.CATCH, tok.CASE, tok.DEFAULT, tok.SWITCH, tok.FUNCTION):
return
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.CASE, tok.DEFAULT)
def missing_break(node):
@@ -424,7 +424,7 @@
return
if None in _get_exit_points(case_contents):
# Show the warning on the *next* node.
- raise LintWarning, node.parent.kids[node.node_index+1]
+ raise LintWarning(node.parent.kids[node.node_index+1])
@lookfor(tok.CASE, tok.DEFAULT)
def missing_break_for_last_case(node):
@@ -433,16 +433,16 @@
case_contents = node.kids[1]
assert case_contents.kind == tok.LC
if None in _get_exit_points(case_contents):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.INC)
def multiple_plus_minus(node):
if node.node_index == 0 and node.parent.kind == tok.PLUS:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.DEC)
def multiple_plus_minus_(node):
if node.node_index == 0 and node.parent.kind == tok.MINUS:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor((tok.NAME, op.SETNAME))
def useless_assign(node):
@@ -452,7 +452,7 @@
elif node.parent.kind == tok.VAR:
value = node.kids[0]
if value and value.kind == tok.NAME and node.atom == value.atom:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.BREAK, tok.CONTINUE, tok.RETURN, tok.THROW)
def unreachable_code(node):
@@ -463,12 +463,12 @@
for variable in sibling.kids:
value, = variable.kids
if value:
- raise LintWarning, value
+ raise LintWarning(value)
elif sibling.kind == tok.FUNCTION:
# Functions are always declared.
pass
else:
- raise LintWarning, sibling
+ raise LintWarning(sibling)
@lookfor(tok.FOR)
def unreachable_code_(node):
@@ -478,73 +478,73 @@
pre, condition, post = preamble.kids
if post:
if not None in _get_exit_points(code):
- raise LintWarning, post
+ raise LintWarning(post)
@lookfor(tok.DO)
def unreachable_code__(node):
# Warn if the do..while loop always exits.
code, condition = node.kids
if not None in _get_exit_points(code):
- raise LintWarning, condition
+ raise LintWarning(condition)
#TODO: @lookfor(tok.IF)
def meaningless_block(node):
condition, if_, else_ = node.kids
if condition.kind == tok.PRIMARY and condition.opcode in (op.TRUE, op.FALSE, op.NULL):
- raise LintWarning, condition
+ raise LintWarning(condition)
#TODO: @lookfor(tok.WHILE)
def meaningless_blocK_(node):
condition = node.kids[0]
if condition.kind == tok.PRIMARY and condition.opcode in (op.FALSE, op.NULL):
- raise LintWarning, condition
+ raise LintWarning(condition)
@lookfor(tok.LC)
def meaningless_block__(node):
if node.parent and node.parent.kind == tok.LC:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor((tok.UNARYOP, op.VOID))
def useless_void(node):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor((tok.LP, op.CALL))
def parseint_missing_radix(node):
if node.kids[0].kind == tok.NAME and node.kids[0].atom == 'parseInt' and len(node.kids) <= 2:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.NUMBER)
def leading_decimal_point(node):
if node.atom.startswith('.'):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.NUMBER)
def trailing_decimal_point(node):
if node.parent.kind == tok.DOT:
- raise LintWarning, node
+ raise LintWarning(node)
if node.atom.endswith('.'):
- raise LintWarning, node
+ raise LintWarning(node)
_octal_regexp = re.compile('^0[0-9]')
@lookfor(tok.NUMBER)
def octal_number(node):
if _octal_regexp.match(node.atom):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.RC)
def trailing_comma(node):
if node.end_comma:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.RB)
def trailing_comma_in_array(node):
if node.end_comma:
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.STRING)
def useless_quotes(node):
if node.node_index == 0 and node.parent.kind == tok.COLON:
# Only warn if the quotes could safely be removed.
if util.isidentifier(node.atom):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(tok.SEMI)
def want_assign_or_call(node):
@@ -566,7 +566,7 @@
grandchild = child.kids[0]
if grandchild.kind == tok.FUNCTION:
return
- raise LintWarning, child
+ raise LintWarning(child)
def _check_return_value(node):
name = node.fn_name or '(anonymous function)'
@@ -605,7 +605,7 @@
assert node.kids[0].kind == tok.IN
left, right = node.kids[0].kids
if not left.kind in (tok.VAR, tok.NAME):
- raise LintWarning, left
+ raise LintWarning(left)
@lookfor(tok.FUNCTION)
def misplaced_function(node):
@@ -635,7 +635,7 @@
return # Allow for return values
if parent.kind == tok.NEW:
return # Allow as constructors
- raise LintWarning, node
+ raise LintWarning(node)
def _get_expected_function_name(node):
# Ignore function statements.
@@ -724,7 +724,7 @@
def missing_semicolon(node):
if node.no_semi:
if not _get_assigned_lambda(node):
- raise LintWarning, node
+ raise LintWarning(node)
@lookfor(*_ALL_TOKENS)
def missing_semicolon_for_lambda(node):
@@ -733,7 +733,7 @@
# statements, so use the position of the lambda instead.
lambda_ = _get_assigned_lambda(node)
if lambda_:
- raise LintWarning, lambda_
+ raise LintWarning(lambda_)
@lookfor()
def ambiguous_newline(node):
Modified: trunk/setup.py
===================================================================
--- trunk/setup.py 2013-10-02 23:16:54 UTC (rev 326)
+++ trunk/setup.py 2013-10-02 23:18:30 UTC (rev 327)
@@ -16,7 +16,7 @@
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if p.returncode != 0:
- raise _BuildError, 'Error running svnversion: %s' % stderr
+ raise _BuildError('Error running svnversion: %s' % stderr)
version = stdout.strip().rstrip('M')
return int(version)
@@ -48,7 +48,7 @@
for exe in self.console_exe_files:
ret = subprocess.call(['upx', '-9', exe])
if ret != 0:
- raise _BuildError, 'Error running upx on %s' % exe
+ raise _BuildError('Error running upx on %s' % exe)
args['cmdclass']['py2exe'] = _MyPy2Exe
args.update(
Modified: trunk/test.py
===================================================================
--- trunk/test.py 2013-10-02 23:16:54 UTC (rev 326)
+++ trunk/test.py 2013-10-02 23:18:30 UTC (rev 327)
@@ -76,7 +76,7 @@
for line, warning, errdesc in unexpected_warnings:
errors.append('\tline %i: %s/%s' % (line+1, warning, errdesc))
if errors:
- raise TestError, '\n'.join(errors)
+ raise TestError('\n'.join(errors))
def _get_test_files():
# Get a list of test files.
@@ -143,7 +143,6 @@
'R0924', # Badly implemented
'W0109', # Duplicate key %r in dictionary
'W0120', # Else clause on loop without a break statement
- 'W0121', # old-raise-syntax
'W0141', # Used builtin function %r
'W0201', # Attribute %r defined outside __init__
'W0212', # Access to a protected member %s of a client class
Modified: trunk/www.py
===================================================================
--- trunk/www.py 2013-10-02 23:16:54 UTC (rev 326)
+++ trunk/www.py 2013-10-02 23:18:30 UTC (rev 327)
@@ -53,7 +53,7 @@
if not attrvalue.startswith('/'):
targetpath = _get_path_for_url(attrvalue, self._filepath)
if not targetpath:
- raise ValueError, 'Could not resolve URL %s' % attrvalue
+ raise ValueError('Could not resolve URL %s' % attrvalue)
# Get the folder of the parent path.
parenturl = _get_relurl_for_filepath(self._filepath)
@@ -89,7 +89,7 @@
root = os.path.dirname(parentpath)
assert (root + os.sep).startswith(DOC_ROOT + os.sep)
else:
- raise ValueError, 'Tried resolving relative URL: %s' % url
+ raise ValueError('Tried resolving relative URL: %s' % url)
urls = [
url.rstrip('/') + '/index.htm',
@@ -136,11 +136,11 @@
channel = doc.createElement("channel")
rss.appendChild(channel)
if not title:
- raise ValueError, 'Missing @title= setting.'
+ raise ValueError('Missing @title= setting.')
if not link:
- raise ValueError, 'Missing @link= setting.'
+ raise ValueError('Missing @link= setting.')
if not desc:
- raise ValueError, 'Missing @desc= setting.'
+ raise ValueError('Missing @desc= setting.')
channel.appendChild(doc.createElement('title', textNode=title))
channel.appendChild(doc.createElement('link', textNode=link))
channel.appendChild(doc.createElement('description', textNode=desc))
@@ -153,7 +153,7 @@
for child in oldDocElement.childNodes:
if child.type != "element":
if child.value.strip():
- raise ValueError, 'Expected outer-level element, not text.'
+ raise ValueError('Expected outer-level element, not text.')
continue
if child.nodeName == 'h1':
@@ -161,24 +161,24 @@
elif child.nodeName == "h2":
link = len(child.childNodes) == 1 and child.childNodes[0]
if not link or link.type != 'element' or link.nodeName != 'a':
- raise ValueError, 'Each heading must be a link.'
+ raise ValueError('Each heading must be a link.')
titlenode = len(link.childNodes) == 1 and link.childNodes[0]
if not titlenode or titlenode.type != 'text':
- raise ValueError, 'Each heading link must contain a ' + \
- 'single text node.'
+ raise ValueError('Each heading link must contain a ' + \
+ 'single text node.')
heading = titlenode.value.strip()
# Combine the href with the linkbase.
assert 'href' in link.attributes
href = link.attribute_values['href']
if not linkbase.endswith('/'):
- raise ValueError, 'The @linkbase must be a directory: %s' % \
- linkbase
+ raise ValueError('The @linkbase must be a directory: %s' % \
+ linkbase)
href = linkbase + href
if href in guids:
- raise ValueError, "Duplicate link: %s" % href
+ raise ValueError("Duplicate link: %s" % href)
guids.append(href)
item = doc.createElement("item")
@@ -193,21 +193,21 @@
# The first paragraph is <p><em>pubDate</em></p>
em = len(child.childNodes) == 1 and child.childNodes[0]
if not em or em.type != 'element' or em.nodeName != 'em':
- raise ValueError, 'The first paragraph must contain ' + \
- 'only an <em>.'
+ raise ValueError('The first paragraph must contain ' + \
+ 'only an <em>.')
emchild = len(em.childNodes) == 1 and em.childNodes[0]
if not emchild or emchild.type != 'text':
- raise ValueError, "The first paragraph's em must " + \
- "contain only text."
+ raise ValueError("The first paragraph's em must " + \
+ "contain only text.")
pubdate = emchild.value
format = "%a, %d %b %Y %H:%M:%S +0000"
dateobj = datetime.datetime.strptime(pubdate, format)
normalized = dateobj.strftime(format)
if normalized != pubdate:
- raise ValueError, 'Encountered date %s but expected %s' % \
- (pubdate, normalized)
+ raise ValueError('Encountered date %s but expected %s' % \
+ (pubdate, normalized))
item.appendChild(doc.createElement('pubDate', emchild.value))
@@ -218,7 +218,7 @@
item_desc.appendChild(cdata)
else:
- raise ValueError, 'Unsupported node type: %s' % child.nodeName
+ raise ValueError('Unsupported node type: %s' % child.nodeName)
return doc.toxml()
def _preprocess(path):
@@ -227,13 +227,13 @@
# will resolve.
url = match.group(1).strip()
if '/' in url:
- raise ValueError, 'Inclusions cannot cross directories'
+ raise ValueError('Inclusions cannot cross directories')
# When including a file, update global settings and replace
# with contents.
includepath = _get_path_for_url(url, path)
if not includepath:
- raise ValueError, 'Unmatched URL: %s' % match.group(1)
+ raise ValueError('Unmatched URL: %s' % match.group(1))
settings, contents = _preprocess(includepath)
childsettings.update(settings)
return contents
@@ -291,7 +291,7 @@
page = open(template_path).read() % keywords
return 'text/html', page
else:
- raise ValueError, 'Invalid file type: %s' % path
+ raise ValueError('Invalid file type: %s' % path)
class _Handler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
@@ -339,7 +339,7 @@
yield relpath
if not host or '/' in host:
- raise ValueError, 'Host must be sub.domain.com'
+ raise ValueError('Host must be sub.domain.com')
for relpath in findfiles(DOC_ROOT):
sourcepath = os.path.join(DOC_ROOT, relpath)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|