Skip to content

Commit

Permalink
More lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Feb 5, 2024
1 parent 42ed183 commit f7436a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions uncompyle6/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class Code(object):
"""

def __init__(self, co, scanner, classname=None, show_asm=None):

# Full initialization is given below, but for linters
# well set up some initial values.
self.co_code = None # Really either bytes for >= 3.0 and string in < 3.0

for i in dir(co):
if i.startswith("co_"):
setattr(self, i, getattr(co, i))
Expand Down
20 changes: 10 additions & 10 deletions uncompyle6/semantics/pysource.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
# evaluating the escape code.

import sys
from io import StringIO

from spark_parser import GenericASTTraversal
from xdis import COMPILER_FLAG_BIT, iscode
Expand Down Expand Up @@ -174,8 +175,6 @@ def unicode(x):
return x


from io import StringIO

PARSER_DEFAULT_DEBUG = {
"rules": False,
"transition": False,
Expand Down Expand Up @@ -384,9 +383,9 @@ def str_with_template1(self, ast, indent, sibNum=None) -> str:
i += 1
return rv

def indent_if_source_nl(self, line_number: int, indent: int):
def indent_if_source_nl(self, line_number: int, indent_spaces: str):
if line_number != self.line_number:
self.write("\n" + indent + INDENT_PER_LEVEL[:-1])
self.write("\n" + indent_spaces + INDENT_PER_LEVEL[:-1])
return self.line_number

f = property(
Expand Down Expand Up @@ -564,6 +563,7 @@ def print_super_classes(self, node):

def print_super_classes3(self, node):
n = len(node) - 1
j = 0
if node.kind != "expr":
if node == "kwarg":
self.template_engine(("(%[0]{attr}=%c)", 1), node)
Expand Down Expand Up @@ -601,9 +601,9 @@ def print_super_classes3(self, node):
self.write("(")
if kwargs:
# Last arg is tuple of keyword values: omit
l = n - 1
m = n - 1
else:
l = n
m = n

if kwargs:
# 3.6+ does this
Expand All @@ -615,15 +615,15 @@ def print_super_classes3(self, node):
j += 1

j = 0
while i < l:
while i < m:
self.write(sep)
value = self.traverse(node[i])
self.write("%s=%s" % (kwargs[j], value))
sep = line_separator
j += 1
i += 1
else:
while i < l:
while i < m:
value = self.traverse(node[i])
i += 1
self.write(sep, value)
Expand Down Expand Up @@ -1093,8 +1093,8 @@ def build_class(self, code):
# if docstring exists, dump it
if code.co_consts and code.co_consts[0] is not None and len(ast) > 0:
do_doc = False
i = 0
if is_docstring(ast[0], self.version, code.co_consts):
i = 0
do_doc = True
elif len(ast) > 1 and is_docstring(ast[1], self.version, code.co_consts):
i = 1
Expand Down Expand Up @@ -1427,12 +1427,12 @@ def deparse_code2str(


if __name__ == "__main__":

def deparse_test(co):
"""This is a docstring"""
s = deparse_code2str(co)
# s = deparse_code2str(co, debug_opts={"asm": "after", "tree": {'before': False, 'after': False}})
print(s)
return


deparse_test(deparse_test.__code__)

0 comments on commit f7436a4

Please sign in to comment.