How to use the pyupgrade.FindPy3Plus function in pyupgrade

To help you get started, we’ve selected a few pyupgrade 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 asottile / pyupgrade / pyupgrade.py View on Github external
def _fix_py3_plus(contents_text):  # type: (str) -> str
    try:
        ast_obj = ast_parse(contents_text)
    except SyntaxError:
        return contents_text

    visitor = FindPy3Plus()
    visitor.visit(ast_obj)

    if not any((
            visitor.bases_to_remove,
            visitor.encode_calls,
            visitor.if_py2_blocks,
            visitor.if_py3_blocks,
            visitor.native_literals,
            visitor.io_open_calls,
            visitor.os_error_alias_calls,
            visitor.os_error_alias_simple,
            visitor.os_error_alias_excepts,
            visitor.six_add_metaclass,
            visitor.six_b,
            visitor.six_calls,
            visitor.six_iter,
github asottile / pyupgrade / pyupgrade.py View on Github external
def generic_visit(self, node):  # type: (ast.AST) -> None
        self._previous_node = node
        super(FindPy3Plus, self).generic_visit(node)

pyupgrade

A tool to automatically upgrade syntax for newer versions.

MIT
Latest version published 1 month ago

Package Health Score

85 / 100
Full package analysis

Similar packages