How to use the pyflakes.messages.ImportStarUsed 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 sailthru / stolos / bin / code_linter.py View on Github external
if offset is not None:
                sys.stderr.write(" " * offset + "^\n")

        return 1
    else:
        # Okay, it's syntactically valid.  Now check it.
        w = checker.Checker(tree, filename)
        lines = codeString.split('\n')
        messages = [message for message in w.messages
                    if lines[message.lineno - 1].find('pyflakes:ignore') < 0]
        messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
        false_positives = 0
        for warning in messages:
            if not (re.match('.*__init__.py', str(warning)) and
                    isinstance(warning, (UnusedImport, ImportStarUsed))):
                print(warning)
            else:
                false_positives += 1
        return len(messages) - false_positives
github asmeurer / mypython / mypython / processors.py View on Github external
def get_pyflakes_warnings(code, defined_names=frozenset(),
                          skip=(UnusedImport, ImportStarUsed, ImportStarUsage)):
    """
    Get pyflakes warnings for code

    Return a list of (row, col, msg, m) tuples, where

    row is the line number (starting at 0),
    col is the column number (starting at 0),
    msg is the string message for the warning, and
    m is the pyflakes Message class for the message

    defined_names should be a frozenset of names which should be considered
    already defined in the global namespace for the code.

    skip should be a tuple of pyflakes message classes to skip.
    """
    from .mypython import validate_text
github kevinw / pyflakes / pyflakes / checker.py View on Github external
def IMPORTFROM(self, node):
        if node.module == '__future__':
            if not self.futuresAllowed:
                self.report(messages.LateFutureImport, node,
                            [n.name for n in node.names])
        else:
            self.futuresAllowed = False

        for alias in node.names:
            if alias.name == '*':
                self.scope.importStarred = True
                self.report(messages.ImportStarUsed, node, node.module)
                continue
            name = alias.asname or alias.name
            importation = Importation(name, node)
            if node.module == '__future__':
                importation.used = (self.scope, node)
            self.addBinding(node, importation)
github SublimeLinter / SublimeLinter / sublimeflakes.py View on Github external
elif isinstance(error, PythonError):
			if len(errors) == 1 and False:
				outlines = [view.full_line(view.text_point(error.lineno, 0)) for lineno in lines]
				view.add_regions('pyflakes-syntax', outlines, 'keyword', drawType)#sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_OUTLINED)
				return

		elif isinstance(error, messages.UnusedImport):
			underlineImport(error.lineno, error.name)
		
		elif isinstance(error, messages.RedefinedWhileUnused):
			underlineWord(error.lineno, error.name)

		elif isinstance(error, messages.ImportShadowedByLoopVar):
			underlineForVar(error.lineno, error.name)

		elif isinstance(error, messages.ImportStarUsed):
			underlineImport(error.lineno, '\*')

		elif isinstance(error, messages.UndefinedName):
			underlineWord(error.lineno, error.name)

		elif isinstance(error, messages.UndefinedExport):
			underlineWord(error.lineno, error.name)

		elif isinstance(error, messages.UndefinedLocal):
			underlineWord(error.lineno, error.name)

		elif isinstance(error, messages.DuplicateArgument):
			underlineDuplicateArgument(error.lineno, error.name)

		elif isinstance(error, messages.RedefinedFunction):
			underlineWord(error.lineno, error.name)
github QQuick / Transcrypt / transcrypt / modules / org / transcrypt / static_check / pyflakes / pyflakes / checker.py View on Github external
def IMPORTFROM(self, node):
        if node.module == '__future__':
            if not self.futuresAllowed:
                self.report(messages.LateFutureImport,
                            node, [n.name for n in node.names])
        else:
            self.futuresAllowed = False

        for alias in node.names:
            if alias.name == '*':
                self.scope.importStarred = True
                self.report(messages.ImportStarUsed, node, node.module)
                continue
            name = alias.asname or alias.name
            importation = Importation(name, node)
            if node.module == '__future__':
                importation.used = (self.scope, node)
            self.addBinding(node, importation)
github marslo / myvim / Configurations / Offline_Packages / bundle / python-mode / pymode / libs / pyflakes / checker.py View on Github external
for alias in node.names:
            name = alias.asname or alias.name
            if node.module == '__future__':
                importation = FutureImportation(name, node, self.scope)
                if alias.name not in __future__.all_feature_names:
                    self.report(messages.FutureFeatureNotDefined,
                                node, alias.name)
            elif alias.name == '*':
                # Only Python 2, local import * is a SyntaxWarning
                if not PY2 and not isinstance(self.scope, ModuleScope):
                    self.report(messages.ImportStarNotPermitted,
                                node, module)
                    continue

                self.scope.importStarred = True
                self.report(messages.ImportStarUsed, node, module)
                importation = StarImportation(module, node)
            else:
                importation = ImportationFrom(name, node,
                                              module, alias.name)
            self.addBinding(node, importation)
github zrzka / blackmamba / blackmamba / lib / pyflakes / checker.py View on Github external
for alias in node.names:
            name = alias.asname or alias.name
            if node.module == '__future__':
                importation = FutureImportation(name, node, self.scope)
                if alias.name not in __future__.all_feature_names:
                    self.report(messages.FutureFeatureNotDefined,
                                node, alias.name)
            elif alias.name == '*':
                # Only Python 2, local import * is a SyntaxWarning
                if not PY2 and not isinstance(self.scope, ModuleScope):
                    self.report(messages.ImportStarNotPermitted,
                                node, module)
                    continue

                self.scope.importStarred = True
                self.report(messages.ImportStarUsed, node, module)
                importation = StarImportation(module, node)
            else:
                importation = ImportationFrom(name, node,
                                              module, alias.name)
            self.addBinding(node, importation)
github asmeurer / removestar / removestar / removestar.py View on Github external
def star_imports(checker):
    stars = []
    for message in checker.messages:
        if isinstance(message, ImportStarUsed):
            stars.append(message.message_args[0])
    return stars
github dreadatour / Flake8Lint / contrib / pyflakes / checker.py View on Github external
def IMPORTFROM(self, node):
        if node.module == '__future__':
            if not self.futuresAllowed:
                self.report(messages.LateFutureImport,
                            node, [n.name for n in node.names])
        else:
            self.futuresAllowed = False

        for alias in node.names:
            if alias.name == '*':
                self.scope.importStarred = True
                self.report(messages.ImportStarUsed, node, node.module)
                continue
            name = alias.asname or alias.name
            importation = Importation(name, node)
            if node.module == '__future__':
                importation.used = (self.scope, node)
            self.addBinding(node, importation)
github mozilla / version-control-tools / pylib / pyflakes / pyflakes / checker.py View on Github external
for alias in node.names:
            name = alias.asname or alias.name
            if node.module == '__future__':
                importation = FutureImportation(name, node, self.scope)
                if alias.name not in __future__.all_feature_names:
                    self.report(messages.FutureFeatureNotDefined,
                                node, alias.name)
            elif alias.name == '*':
                # Only Python 2, local import * is a SyntaxWarning
                if not PY2 and not isinstance(self.scope, ModuleScope):
                    self.report(messages.ImportStarNotPermitted,
                                node, module)
                    continue

                self.scope.importStarred = True
                self.report(messages.ImportStarUsed, node, module)
                importation = StarImportation(module, node)
            else:
                importation = ImportationFrom(name, node,
                                              module, alias.name)
            self.addBinding(node, importation)