You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix spelling via "codespell"
This commit is contained in:
@@ -21,7 +21,7 @@ def checker(ast, in_loop, errors):
|
||||
if ast.kind in ("aug_assign1", "aug_assign2") and ast[0][0] == "and":
|
||||
text = str(ast)
|
||||
error_text = (
|
||||
"\n# improper augmented assigment (e.g. +=, *=, ...):\n#\t"
|
||||
"\n# improper augmented assignment (e.g. +=, *=, ...):\n#\t"
|
||||
+ "\n# ".join(text.split("\n"))
|
||||
+ "\n"
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2017-2022 by Rocky Bernstein
|
||||
# Copyright (c) 2017-2023 by Rocky Bernstein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -22,7 +22,7 @@ minint = -sys.maxsize - 1
|
||||
maxint = sys.maxsize
|
||||
|
||||
|
||||
# Operator precidence See
|
||||
# Operator precedence See
|
||||
# https://docs.python.org/2/reference/expressions.html#operator-precedence
|
||||
# or
|
||||
# https://docs.python.org/3/reference/expressions.html#operator-precedence
|
||||
@@ -37,11 +37,11 @@ maxint = sys.maxsize
|
||||
# various templates we use odd values. Avoiding equal-precedent comparisons
|
||||
# avoids ambiguity what to do when the precedence is equal.
|
||||
|
||||
# The precidence of a key below applies the key, a node, and the its
|
||||
# *parent*. A node however sometimes sets the precidence for its
|
||||
# children. For example, "call" has precidence 2 so we don't get
|
||||
# The precedence of a key below applies the key, a node, and the its
|
||||
# *parent*. A node however sometimes sets the precedence for its
|
||||
# children. For example, "call" has precedence 2 so we don't get
|
||||
# additional the additional parenthesis of: ".. op (call())". However
|
||||
# for call's children, it parameters, we set the the precidence high,
|
||||
# for call's children, it parameters, we set the the precedence high,
|
||||
# say to 100, to make sure we avoid additional prenthesis in
|
||||
# call((.. op ..)).
|
||||
|
||||
@@ -428,7 +428,7 @@ TABLE_DIRECT = {
|
||||
|
||||
"expr_stmt": (
|
||||
"%|%p\n",
|
||||
# When a statment contains only a named_expr (:=)
|
||||
# When a statement contains only a named_expr (:=)
|
||||
# the named_expr should have parenthesis around it.
|
||||
(0, "expr", PRECEDENCE["named_expr"] - 1)
|
||||
),
|
||||
|
@@ -226,7 +226,7 @@ def customize_for_version3(self, version):
|
||||
assert node[0] == "expr"
|
||||
if node[0][0] == "get_iter":
|
||||
# Skip over yield_from.expr.get_iter which adds an
|
||||
# extra iter(). Maybe we can do in tranformation phase instead?
|
||||
# extra iter(). Maybe we can do in transformation phase instead?
|
||||
template = ("yield from %c", (0, "expr"))
|
||||
self.template_engine(template, node[0][0])
|
||||
else:
|
||||
@@ -318,7 +318,7 @@ def customize_for_version3(self, version):
|
||||
# FIXME: the real situation is that when derived from
|
||||
# function_def_annotate we the name has been filled in.
|
||||
# But when derived from funcdefdeco it hasn't Would like a better
|
||||
# way to distinquish.
|
||||
# way to distinguish.
|
||||
if self.f.getvalue()[-4:] == "def ":
|
||||
self.write(get_code_name(code_node.attr))
|
||||
|
||||
|
@@ -1347,7 +1347,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
selectedText = text[start:finish]
|
||||
|
||||
# Compute offsets relative to the beginning of the
|
||||
# line rather than the beinning of the text
|
||||
# line rather than the beginning of the text.
|
||||
try:
|
||||
lineStart = text[:start].rindex("\n") + 1
|
||||
except ValueError:
|
||||
@@ -1355,7 +1355,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
adjustedStart = start - lineStart
|
||||
|
||||
# If selected text is greater than a single line
|
||||
# just show the first line plus elipses.
|
||||
# just show the first line plus ellipsis.
|
||||
lines = selectedText.split("\n")
|
||||
if len(lines) > 1:
|
||||
adjustedEnd = len(lines[0]) - adjustedStart
|
||||
@@ -1428,7 +1428,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
p = node.parent
|
||||
orig_parent = p
|
||||
# If we can get different text, use that as the parent,
|
||||
# otherwise we'll use the immeditate parent
|
||||
# otherwise we'll use the immediatate parent.
|
||||
while p and (
|
||||
hasattr(p, "parent") and p.start == node.start and p.finish == node.finish
|
||||
):
|
||||
@@ -1778,7 +1778,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
n_set = n_tuple = n_build_set = n_list
|
||||
|
||||
def template_engine(self, entry, startnode):
|
||||
"""The format template interpetation engine. See the comment at the
|
||||
"""The format template interpretation engine. See the comment at the
|
||||
beginning of this module for the how we interpret format
|
||||
specifications such as %c, %C, and so on.
|
||||
"""
|
||||
@@ -1961,7 +1961,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
|
||||
# FIXME figure out how to get these cases to be table driven.
|
||||
# 2. subroutine calls. It the last op is the call and for purposes of printing
|
||||
# we don't need to print anything special there. However it encompases the
|
||||
# we don't need to print anything special there. However it encompasses the
|
||||
# entire string of the node fn(...)
|
||||
if startnode.kind == "call":
|
||||
last_node = startnode[-1]
|
||||
@@ -2166,7 +2166,7 @@ def code_deparse_around_offset(
|
||||
return deparsed
|
||||
|
||||
|
||||
# Deprecated. Here still for compatability
|
||||
# Deprecated. Here still for compatibility
|
||||
def deparse_code_around_offset(
|
||||
name,
|
||||
offset,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2022 Rocky Bernstein
|
||||
# Copyright (c) 2022-2023 Rocky Bernstein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -43,7 +43,7 @@ def escape_string(s, quotes=('"', "'", '"""', "'''")):
|
||||
s = s.replace(orig, replace)
|
||||
return "%s%s%s" % (quote, s, quote)
|
||||
|
||||
# FIXME: this and find_globals could be paramaterized with one of the
|
||||
# FIXME: this and find_globals could be parameterized with one of the
|
||||
# above global ops
|
||||
def find_all_globals(node, globs):
|
||||
"""Search Syntax Tree node to find variable names that are global."""
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2022 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2023 by Rocky Bernstein
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -31,7 +31,7 @@ from xdis import iscode
|
||||
|
||||
def make_function1(self, node, is_lambda, nested=1, code_node=None):
|
||||
"""
|
||||
Dump function defintion, doc string, and function body.
|
||||
Dump function definition, doc string, and function body.
|
||||
This code is specialied for Python 2.
|
||||
"""
|
||||
|
||||
@@ -40,7 +40,7 @@ def make_function1(self, node, is_lambda, nested=1, code_node=None):
|
||||
- handle defaults
|
||||
- handle format tuple parameters
|
||||
"""
|
||||
# if formal parameter is a tuple, the paramater name
|
||||
# if formal parameter is a tuple, the parameter name
|
||||
# starts with a dot (eg. '.1', '.2')
|
||||
args = tree[0]
|
||||
del tree[0]
|
||||
|
@@ -34,7 +34,7 @@ from uncompyle6.show import maybe_show_tree_param_default
|
||||
|
||||
def make_function2(self, node, is_lambda, nested=1, code_node=None):
|
||||
"""
|
||||
Dump function defintion, doc string, and function body.
|
||||
Dump function definition, doc string, and function body.
|
||||
This code is specialied for Python 2.
|
||||
"""
|
||||
|
||||
|
@@ -37,7 +37,7 @@ def make_function3_annotate(
|
||||
self, node, is_lambda, nested=1, code_node=None, annotate_last=-1
|
||||
):
|
||||
"""
|
||||
Dump function defintion, doc string, and function
|
||||
Dump function definition, doc string, and function
|
||||
body. This code is specialized for Python 3"""
|
||||
|
||||
def build_param(ast, name, default):
|
||||
@@ -310,7 +310,7 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
||||
# the object on the stack, for keyword-only parameters
|
||||
# * parameter annotation objects
|
||||
# * a tuple listing the parameter names for the annotations
|
||||
# (only if there are ony annotation objects)
|
||||
# (only if there are only annotation objects)
|
||||
# * the code associated with the function (at TOS1)
|
||||
# * the qualified name of the function (at TOS)
|
||||
|
||||
|
@@ -91,7 +91,7 @@ Python.
|
||||
# the second item is the nonterminal name and the precedence is given last.
|
||||
#
|
||||
# %C evaluate/travers children recursively, with sibling children separated by the
|
||||
# given string. It needs a 3-tuple: a starting node, the maximimum
|
||||
# given string. It needs a 3-tuple: a starting node, the maximum
|
||||
# value of an end node, and a string to be inserted between sibling children
|
||||
#
|
||||
# %, Append ',' if last %C only printed one item. This is mostly for tuples
|
||||
@@ -99,12 +99,12 @@ Python.
|
||||
# other tuples. The specifier takes no arguments
|
||||
#
|
||||
# %P same as %C but sets operator precedence. Its argument is a 4-tuple:
|
||||
# the node low and high indices, the separator, a string the precidence
|
||||
# the node low and high indices, the separator, a string the precedence
|
||||
# value, an integer.
|
||||
#
|
||||
# %D Same as `%C` this is for left-recursive lists like kwargs where goes
|
||||
# to epsilon at the beginning. It needs a 3-tuple: a starting node, the
|
||||
# maximimum value of an end node, and a string to be inserted between
|
||||
# maximum value of an end node, and a string to be inserted between
|
||||
# sibling children. If we were to use `%C` an extra separator with an
|
||||
# epsilon would appear at the beginning.
|
||||
#
|
||||
@@ -119,7 +119,7 @@ Python.
|
||||
# %[N]{EXPR} Python eval(EXPR) in context of node[N]. Takes no arguments
|
||||
#
|
||||
# %[N]{%X} evaluate/recurse on child node[N], using specifier %X.
|
||||
# %X can be one of the above, e.g. %c, %p, etc. Takes the arguemnts
|
||||
# %X can be one of the above, e.g. %c, %p, etc. Takes the arguments
|
||||
# that the specifier uses.
|
||||
#
|
||||
# %% literal '%'. Takes no arguments.
|
||||
@@ -214,22 +214,22 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
|
||||
of both the syntax tree and language we should produce.
|
||||
|
||||
`out' is IO-like file pointer to where the output should go. It
|
||||
whould have a getvalue() method.
|
||||
would have a getvalue() method.
|
||||
|
||||
`scanner' is a method to call when we need to scan tokens. Sometimes
|
||||
in producing output we will run across further tokens that need
|
||||
to be scaned.
|
||||
to be scanned.
|
||||
|
||||
If `showast' is True, we print the syntax tree.
|
||||
|
||||
`compile_mode' is is either 'exec' or 'single'. It is the compile
|
||||
mode that was used to create the Syntax Tree and specifies a
|
||||
gramar variant within a Python version to use.
|
||||
grammar variant within a Python version to use.
|
||||
|
||||
`is_pypy` should be True if the Syntax Tree was generated for PyPy.
|
||||
|
||||
`linestarts` is a dictionary of line number to bytecode offset. This
|
||||
can sometimes assist in determinte which kind of source-code construct
|
||||
can sometimes assist in determining which kind of source-code construct
|
||||
to use when there is ambiguity.
|
||||
|
||||
"""
|
||||
@@ -680,7 +680,7 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
|
||||
pass
|
||||
|
||||
def template_engine(self, entry, startnode):
|
||||
"""The format template interpetation engine. See the comment at the
|
||||
"""The format template interpretation engine. See the comment at the
|
||||
beginning of this module for the how we interpret format
|
||||
specifications such as %c, %C, and so on.
|
||||
"""
|
||||
@@ -970,7 +970,7 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
|
||||
# within the function definition
|
||||
assert node[1] == "store"
|
||||
# if lhs is not a UNPACK_TUPLE (or equiv.),
|
||||
# add parenteses to make this a tuple
|
||||
# add parentheses to make this a tuple
|
||||
# if node[1][0] not in ('unpack', 'unpack_list'):
|
||||
result = self.traverse(node[1])
|
||||
if not (result.startswith("(") and result.endswith(")")):
|
||||
|
@@ -263,7 +263,7 @@ class TreeTransform(GenericASTTraversal, object):
|
||||
# if elif elif
|
||||
def n_ifelsestmt(self, node, preprocess=False):
|
||||
"""
|
||||
Transformation involving if..else statments.
|
||||
Transformation involving if..else statements.
|
||||
For example
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user