How to use the pyflakes.messages.DuplicateArgument function in pyflakes

To help you get started, we’ve selected a few pyflakes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SublimeLinter / SublimeLinter / sublimeflakes.py View on Github external
raise SyntaxError(None)
			raise
	except (SyntaxError, IndentationError), value:
		# print traceback.format_exc() # helps debug new cases
		msg = value.args[0]

		lineno, offset, text = value.lineno, value.offset, value.text

		# If there's an encoding problem with the file, the text is None.
		if text is None:
			# Avoid using msg, since for the only known case, it contains a
			# bogus message that claims the encoding the file declared was
			# unknown.
			if msg.startswith('duplicate argument'):
				arg = msg.split('duplicate argument ',1)[1].split(' ',1)[0].strip('\'"')
				error = messages.DuplicateArgument(filename, lineno, arg)
			else:
				error = PythonError(filename, lineno, msg)
		else:
			line = text.splitlines()[-1]

			if offset is not None:
				offset = offset - (len(text) - len(line))

			if offset is not None:
				error = OffsetError(filename, lineno, msg, offset)
			else:
				error = PythonError(filename, lineno, msg)

		return [error]
	else:
		# Okay, it's syntactically valid.  Now parse it into an ast and check
github klen / pylama / pylama / lint / pylama_pyflakes / pyflakes / checker.py View on Github external
continue
            args.append(wildcard if PY33 else wildcard.arg)
            if is_py3_func:
                if PY33:  # Python 2.5 to 3.3
                    argannotation = arg_name + 'annotation'
                    annotations.append(getattr(node.args, argannotation))
                else:     # Python >= 3.4
                    annotations.append(wildcard.annotation)

        if is_py3_func:
            annotations.append(node.returns)

        if len(set(args)) < len(args):
            for (idx, arg) in enumerate(args):
                if arg in args[:idx]:
                    self.report(messages.DuplicateArgument, node, arg)

        for child in annotations + defaults:
            if child:
                self.handleNode(child, node)

        def runFunction():

            self.pushScope()
            for name in args:
                self.addBinding(node, Argument(name, node))
            if isinstance(node.body, list):
                # case for FunctionDefs
                for stmt in node.body:
                    self.handleNode(stmt, node)
            else:
                # case for Lambdas
github spyder-ide / spyder / external-py3 / pyflakes / checker.py View on Github external
def addArgs(arglist):
                for arg in arglist:
                    if isinstance(arg, ast.Tuple):
                        addArgs(arg.elts)
                    else:
                        if arg.id in args:
                            self.report(messages.DuplicateArgument,
                                        node, arg.id)
                        args.append(arg.id)
            addArgs(node.args.args)
github pymedphys / pymedphys / app / packages / pyodide-language-server / pyls / plugins / pyflakes_lint.py View on Github external
# Copyright 2017 Palantir Technologies, Inc.
from pyflakes import api as pyflakes_api, messages
from pyls import hookimpl, lsp

# Pyflakes messages that should be reported as Errors instead of Warns
PYFLAKES_ERROR_MESSAGES = (
    messages.UndefinedName,
    messages.UndefinedExport,
    messages.UndefinedLocal,
    messages.DuplicateArgument,
    messages.FutureFeatureNotDefined,
    messages.ReturnOutsideFunction,
    messages.YieldOutsideFunction,
    messages.ContinueOutsideLoop,
    messages.BreakOutsideLoop,
    messages.ContinueInFinally,
    messages.TwoStarredExpressions,
)


@hookimpl
def pyls_lint(document):
    reporter = PyflakesDiagnosticReport(document.lines)
    pyflakes_api.check(
        document.source.encode("utf-8"), document.path, reporter=reporter
    )
github marslo / myvim / Configurations / Offline_Packages / bundle / pyflakes / pyflakes / checker.py View on Github external
continue
            args.append(wildcard if PY2 else wildcard.arg)
            if is_py3_func:
                if PY2:  # Python 2.7
                    argannotation = arg_name + 'annotation'
                    annotations.append(getattr(node.args, argannotation))
                else:     # Python >= 3.4
                    annotations.append(wildcard.annotation)

        if is_py3_func:
            annotations.append(node.returns)

        if len(set(args)) < len(args):
            for (idx, arg) in enumerate(args):
                if arg in args[:idx]:
                    self.report(messages.DuplicateArgument, node, arg)

        for annotation in annotations:
            self.handleAnnotation(annotation, node)

        for default in defaults:
            self.handleNode(default, node)

        def runFunction():

            self.pushScope()
            for name in args:
                self.addBinding(node, Argument(name, node))
            if isinstance(node.body, list):
                # case for FunctionDefs
                for stmt in node.body:
                    self.handleNode(stmt, node)
github robmadole / jig-plugins / pyflakes / lib / pyflakes / checker.py View on Github external
continue
            args.append(wildcard if PY33 else wildcard.arg)
            if is_py3_func:
                if PY33:  # Python 2.5 to 3.3
                    argannotation = arg_name + 'annotation'
                    annotations.append(getattr(node.args, argannotation))
                else:     # Python >= 3.4
                    annotations.append(wildcard.annotation)

        if is_py3_func:
            annotations.append(node.returns)

        if len(set(args)) < len(args):
            for (idx, arg) in enumerate(args):
                if arg in args[:idx]:
                    self.report(messages.DuplicateArgument, node, arg)

        for child in annotations + defaults:
            if child:
                self.handleNode(child, node)

        def runFunction():

            self.pushScope()
            for name in args:
                self.addBinding(node, Argument(name, node))
            if isinstance(node.body, list):
                # case for FunctionDefs
                for stmt in node.body:
                    self.handleNode(stmt, node)
            else:
                # case for Lambdas
github marslo / myvim / Configurations / Offline_Packages / bundle / python-mode / pymode / libs / pyflakes / checker.py View on Github external
continue
            args.append(wildcard if PY33 else wildcard.arg)
            if is_py3_func:
                if PY33:  # Python 2.5 to 3.3
                    argannotation = arg_name + 'annotation'
                    annotations.append(getattr(node.args, argannotation))
                else:     # Python >= 3.4
                    annotations.append(wildcard.annotation)

        if is_py3_func:
            annotations.append(node.returns)

        if len(set(args)) < len(args):
            for (idx, arg) in enumerate(args):
                if arg in args[:idx]:
                    self.report(messages.DuplicateArgument, node, arg)

        for child in annotations + defaults:
            if child:
                self.handleNode(child, node)

        def runFunction():

            self.pushScope()
            for name in args:
                self.addBinding(node, Argument(name, node))
            if isinstance(node.body, list):
                # case for FunctionDefs
                for stmt in node.body:
                    self.handleNode(stmt, node)
            else:
                # case for Lambdas
github DamnWidget / anaconda / anaconda_lib / linting / pyflakes / checker.py View on Github external
continue
            args.append(wildcard if PY2 else wildcard.arg)
            if is_py3_func:
                if PY2:  # Python 2.7
                    argannotation = arg_name + 'annotation'
                    annotations.append(getattr(node.args, argannotation))
                else:     # Python >= 3.4
                    annotations.append(wildcard.annotation)

        if is_py3_func:
            annotations.append(node.returns)

        if len(set(args)) < len(args):
            for (idx, arg) in enumerate(args):
                if arg in args[:idx]:
                    self.report(messages.DuplicateArgument, node, arg)

        for annotation in annotations:
            self.handleAnnotation(annotation, node)

        for default in defaults:
            self.handleNode(default, node)

        def runFunction():

            self.pushScope()

            self.handleChildren(node, omit='decorator_list')

            def checkUnusedAssignments():
                """
                Check to see if any assignments have not been used.