diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Lib/lib2to3 | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Lib/lib2to3')
16 files changed, 60 insertions, 60 deletions
diff --git a/contrib/tools/python3/src/Lib/lib2to3/__init__.py b/contrib/tools/python3/src/Lib/lib2to3/__init__.py index 659060d232..4224dffef4 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/__init__.py +++ b/contrib/tools/python3/src/Lib/lib2to3/__init__.py @@ -1,8 +1,8 @@ -import warnings - - -warnings.warn( - "lib2to3 package is deprecated and may not be able to parse Python 3.10+", - PendingDeprecationWarning, - stacklevel=2, -) +import warnings + + +warnings.warn( + "lib2to3 package is deprecated and may not be able to parse Python 3.10+", + PendingDeprecationWarning, + stacklevel=2, +) diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixer_util.py b/contrib/tools/python3/src/Lib/lib2to3/fixer_util.py index 71c6a47ffc..c2a3a47f50 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixer_util.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixer_util.py @@ -412,7 +412,7 @@ def _find(name, node): return None def _is_import_binding(node, name, package=None): - """ Will return node if node will import name, or node + """ Will return node if node will import name, or node will import * from package. None is returned otherwise. See test cases for examples. """ diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_apply.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_apply.py index a3db0f7e45..6408582c42 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_apply.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_apply.py @@ -38,7 +38,7 @@ class FixApply(fixer_base.BaseFix): # PATTERN above but I don't know how to do it so... if args: if (args.type == self.syms.argument and - args.children[0].value in {'**', '*'}): + args.children[0].value in {'**', '*'}): return # Make no change. if kwds and (kwds.type == self.syms.argument and kwds.children[0].value == '**'): diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_filter.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_filter.py index df43ead490..38e9078f11 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_filter.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_filter.py @@ -17,7 +17,7 @@ Python 2.6 figure it out. from .. import fixer_base from ..pytree import Node from ..pygram import python_symbols as syms -from ..fixer_util import Name, ArgList, ListComp, in_special_context, parenthesize +from ..fixer_util import Name, ArgList, ListComp, in_special_context, parenthesize class FixFilter(fixer_base.ConditionalFix): @@ -65,14 +65,14 @@ class FixFilter(fixer_base.ConditionalFix): trailers.append(t.clone()) if "filter_lambda" in results: - xp = results.get("xp").clone() - if xp.type == syms.test: - xp.prefix = "" - xp = parenthesize(xp) - + xp = results.get("xp").clone() + if xp.type == syms.test: + xp.prefix = "" + xp = parenthesize(xp) + new = ListComp(results.get("fp").clone(), results.get("fp").clone(), - results.get("it").clone(), xp) + results.get("it").clone(), xp) new = Node(syms.power, [new] + trailers, prefix="") elif "none" in results: diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_intern.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_intern.py index 2e6a78b911..d752843092 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_intern.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_intern.py @@ -31,7 +31,7 @@ class FixIntern(fixer_base.BaseFix): obj = results['obj'] if obj: if (obj.type == self.syms.argument and - obj.children[0].value in {'**', '*'}): + obj.children[0].value in {'**', '*'}): return # Make no change. names = ('sys', 'intern') new = ImportAndCall(node, results, names) diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_metaclass.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_metaclass.py index d2253ac79d..fe547b2228 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_metaclass.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_metaclass.py @@ -1,6 +1,6 @@ """Fixer for __metaclass__ = X -> (metaclass=X) methods. - The various forms of classef (inherits nothing, inherits once, inherits + The various forms of classef (inherits nothing, inherits once, inherits many) don't parse the same in the CST so we look at ALL classes for a __metaclass__ and if we find one normalize the inherits to all be an arglist. @@ -51,7 +51,7 @@ def fixup_parse_tree(cls_node): # already in the preferred format, do nothing return - # !%@#! one-liners have no suite node, we have to fake one up + # !%@#! one-liners have no suite node, we have to fake one up for i, node in enumerate(cls_node.children): if node.type == token.COLON: break diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_paren.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_paren.py index be5129e67d..df3da5f523 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_paren.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_paren.py @@ -1,4 +1,4 @@ -"""Fixer that adds parentheses where they are required +"""Fixer that adds parentheses where they are required This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.""" diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_reload.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_reload.py index c1649aedcc..b30841131c 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_reload.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_reload.py @@ -28,7 +28,7 @@ class FixReload(fixer_base.BaseFix): obj = results['obj'] if obj: if (obj.type == self.syms.argument and - obj.children[0].value in {'**', '*'}): + obj.children[0].value in {'**', '*'}): return # Make no change. names = ('importlib', 'reload') new = ImportAndCall(node, results, names) diff --git a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_urllib.py b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_urllib.py index 1c754df047..ab892bc524 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_urllib.py +++ b/contrib/tools/python3/src/Lib/lib2to3/fixes/fix_urllib.py @@ -13,7 +13,7 @@ MAPPING = {"urllib": [ ("urllib.request", ["URLopener", "FancyURLopener", "urlretrieve", "_urlopener", "urlopen", "urlcleanup", - "pathname2url", "url2pathname", "getproxies"]), + "pathname2url", "url2pathname", "getproxies"]), ("urllib.parse", ["quote", "quote_plus", "unquote", "unquote_plus", "urlencode", "splitattr", "splithost", "splitnport", diff --git a/contrib/tools/python3/src/Lib/lib2to3/main.py b/contrib/tools/python3/src/Lib/lib2to3/main.py index 473ab6c841..f2849fd6be 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/main.py +++ b/contrib/tools/python3/src/Lib/lib2to3/main.py @@ -90,11 +90,11 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool): if os.path.lexists(backup): try: os.remove(backup) - except OSError: + except OSError: self.log_message("Can't remove backup %s", backup) try: os.rename(filename, backup) - except OSError: + except OSError: self.log_message("Can't rename %s to %s", filename, backup) # Actually write the new file write = super(StdoutRefactoringTool, self).write_file @@ -154,8 +154,8 @@ def main(fixer_pkg, args=None): help="List available transformations") parser.add_option("-p", "--print-function", action="store_true", help="Modify the grammar so that print() is a function") - parser.add_option("-e", "--exec-function", action="store_true", - help="Modify the grammar so that exec() is a function") + parser.add_option("-e", "--exec-function", action="store_true", + help="Modify the grammar so that exec() is a function") parser.add_option("-v", "--verbose", action="store_true", help="More verbose logging") parser.add_option("--no-diffs", action="store_true", @@ -213,9 +213,9 @@ def main(fixer_pkg, args=None): if options.print_function: flags["print_function"] = True - if options.exec_function: - flags["exec_function"] = True - + if options.exec_function: + flags["exec_function"] = True + # Set up logging handler level = logging.DEBUG if options.verbose else logging.INFO logging.basicConfig(format='%(name)s: %(message)s', level=level) diff --git a/contrib/tools/python3/src/Lib/lib2to3/pgen2/grammar.py b/contrib/tools/python3/src/Lib/lib2to3/pgen2/grammar.py index bddf785dbb..6a4d575ac2 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/pgen2/grammar.py +++ b/contrib/tools/python3/src/Lib/lib2to3/pgen2/grammar.py @@ -85,9 +85,9 @@ class Grammar(object): self.start = 256 def dump(self, filename): - """Dump the grammar tables to a pickle file.""" + """Dump the grammar tables to a pickle file.""" with open(filename, "wb") as f: - pickle.dump(self.__dict__, f, pickle.HIGHEST_PROTOCOL) + pickle.dump(self.__dict__, f, pickle.HIGHEST_PROTOCOL) def load(self, filename): """Load the grammar tables from a pickle file.""" @@ -178,7 +178,7 @@ opmap_raw = """ // DOUBLESLASH //= DOUBLESLASHEQUAL -> RARROW -:= COLONEQUAL +:= COLONEQUAL """ opmap = {} diff --git a/contrib/tools/python3/src/Lib/lib2to3/pgen2/parse.py b/contrib/tools/python3/src/Lib/lib2to3/pgen2/parse.py index 1b6117174e..cf3fcf7e99 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/pgen2/parse.py +++ b/contrib/tools/python3/src/Lib/lib2to3/pgen2/parse.py @@ -24,9 +24,9 @@ class ParseError(Exception): self.value = value self.context = context - def __reduce__(self): - return type(self), (self.msg, self.type, self.value, self.context) - + def __reduce__(self): + return type(self), (self.msg, self.type, self.value, self.context) + class Parser(object): """Parser engine. diff --git a/contrib/tools/python3/src/Lib/lib2to3/pgen2/token.py b/contrib/tools/python3/src/Lib/lib2to3/pgen2/token.py index 1ab43f697d..5f6612f5b3 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/pgen2/token.py +++ b/contrib/tools/python3/src/Lib/lib2to3/pgen2/token.py @@ -65,8 +65,8 @@ RARROW = 55 AWAIT = 56 ASYNC = 57 ERRORTOKEN = 58 -COLONEQUAL = 59 -N_TOKENS = 60 +COLONEQUAL = 59 +N_TOKENS = 60 NT_OFFSET = 256 #--end constants-- diff --git a/contrib/tools/python3/src/Lib/lib2to3/pgen2/tokenize.py b/contrib/tools/python3/src/Lib/lib2to3/pgen2/tokenize.py index 19db93a72d..099dfa7798 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/pgen2/tokenize.py +++ b/contrib/tools/python3/src/Lib/lib2to3/pgen2/tokenize.py @@ -93,7 +93,7 @@ Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=", r"~") Bracket = '[][(){}]' -Special = group(r'\r?\n', r':=', r'[:;.,`@]') +Special = group(r'\r?\n', r':=', r'[:;.,`@]') Funny = group(Operator, Bracket, Special) PlainToken = group(Number, Funny, String, Name) @@ -321,7 +321,7 @@ def untokenize(iterable): Round-trip invariant for full input: Untokenized source will match input source exactly - Round-trip invariant for limited input: + Round-trip invariant for limited input: # Output text will tokenize the back to the input t1 = [tok[:2] for tok in generate_tokens(f.readline)] newcode = untokenize(t1) @@ -346,7 +346,7 @@ def generate_tokens(readline): column where the token begins in the source; a 2-tuple (erow, ecol) of ints specifying the row and column where the token ends in the source; and the line on which the token was found. The line passed is the - physical line. + physical line. """ lnum = parenlev = continued = 0 contstr, needcont = '', 0 @@ -512,14 +512,14 @@ def generate_tokens(readline): stashed = tok continue - if token in ('def', 'for'): + if token in ('def', 'for'): if (stashed and stashed[0] == NAME and stashed[1] == 'async'): - if token == 'def': - async_def = True - async_def_indent = indents[-1] + if token == 'def': + async_def = True + async_def_indent = indents[-1] yield (ASYNC, stashed[1], stashed[2], stashed[3], diff --git a/contrib/tools/python3/src/Lib/lib2to3/pygram.py b/contrib/tools/python3/src/Lib/lib2to3/pygram.py index 20f6cc01f1..24d9db9217 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/pygram.py +++ b/contrib/tools/python3/src/Lib/lib2to3/pygram.py @@ -36,8 +36,8 @@ python_symbols = Symbols(python_grammar) python_grammar_no_print_statement = python_grammar.copy() del python_grammar_no_print_statement.keywords["print"] -python_grammar_no_print_and_exec_statement = python_grammar_no_print_statement.copy() -del python_grammar_no_print_and_exec_statement.keywords["exec"] - +python_grammar_no_print_and_exec_statement = python_grammar_no_print_statement.copy() +del python_grammar_no_print_and_exec_statement.keywords["exec"] + pattern_grammar = driver.load_packaged_grammar("lib2to3", _PATTERN_GRAMMAR_FILE) pattern_symbols = Symbols(pattern_grammar) diff --git a/contrib/tools/python3/src/Lib/lib2to3/refactor.py b/contrib/tools/python3/src/Lib/lib2to3/refactor.py index 07273d2c42..3a5aafffc6 100644 --- a/contrib/tools/python3/src/Lib/lib2to3/refactor.py +++ b/contrib/tools/python3/src/Lib/lib2to3/refactor.py @@ -14,7 +14,7 @@ __author__ = "Guido van Rossum <guido@python.org>" # Python imports import io import os -import pkgutil +import pkgutil import sys import logging import operator @@ -32,11 +32,11 @@ def get_all_fix_names(fixer_pkg, remove_prefix=True): """Return a sorted list of all available fix names in the given package.""" pkg = __import__(fixer_pkg, [], [], ["*"]) fix_names = [] - for finder, name, ispkg in pkgutil.iter_modules(pkg.__path__): - if name.startswith("fix_"): + for finder, name, ispkg in pkgutil.iter_modules(pkg.__path__): + if name.startswith("fix_"): if remove_prefix: name = name[4:] - fix_names.append(name) + fix_names.append(name) return fix_names @@ -155,7 +155,7 @@ class FixerError(Exception): class RefactoringTool(object): _default_options = {"print_function" : False, - "exec_function": False, + "exec_function": False, "write_unchanged_files" : False} CLASS_PREFIX = "Fix" # The prefix for fixer classes @@ -174,13 +174,13 @@ class RefactoringTool(object): self.options = self._default_options.copy() if options is not None: self.options.update(options) - self.grammar = pygram.python_grammar.copy() - - if self.options['print_function']: - del self.grammar.keywords["print"] - elif self.options['exec_function']: - del self.grammar.keywords["exec"] - + self.grammar = pygram.python_grammar.copy() + + if self.options['print_function']: + del self.grammar.keywords["print"] + elif self.options['exec_function']: + del self.grammar.keywords["exec"] + # When this is True, the refactor*() methods will call write_file() for # files processed even if they were not changed during refactoring. If # and only if the refactor method's write parameter was True. |