Skip to content

Commit c8387a3

Browse files
[lldb] Format more Python files with black (#65979)
By running this from lldb/ $ black --exclude "third_party/|scripts/|utils/" ./
1 parent 6bf6c47 commit c8387a3

File tree

8 files changed

+164
-111
lines changed

8 files changed

+164
-111
lines changed

lldb/bindings/python/createPythonInit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pkgFiles = sys.argv[2:]
66

77
getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
8-
importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
8+
importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
99

1010
script = """__all__ = [{import_names}]
1111
for x in __all__:
@@ -18,7 +18,9 @@ def __lldb_init_module(debugger, internal_dict):
1818
lldb_init = getattr(submodule, '__lldb_init_module', None)
1919
if lldb_init:
2020
lldb_init(debugger, internal_dict)
21-
""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
21+
""".format(
22+
import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
23+
)
2224

2325
pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
2426
with open(pkgIniFile, "w") as f:

lldb/bindings/python/get-python-config.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ def relpath_nodots(path, base):
1010
rel = os.path.normpath(os.path.relpath(path, base))
1111
assert not os.path.isabs(rel)
1212
parts = rel.split(os.path.sep)
13-
if parts and parts[0] == '..':
13+
if parts and parts[0] == "..":
1414
raise ValueError(f"{path} is not under {base}")
1515
return rel
1616

17+
1718
def main():
1819
parser = argparse.ArgumentParser(description="extract cmake variables from python")
1920
parser.add_argument("variable_name")
@@ -35,10 +36,10 @@ def main():
3536
except ValueError:
3637
# Try to fall back to something reasonable if sysconfig's platlib
3738
# is outside of sys.prefix
38-
if os.name == 'posix':
39-
print('lib/python%d.%d/site-packages' % sys.version_info[:2])
40-
elif os.name == 'nt':
41-
print('Lib\\site-packages')
39+
if os.name == "posix":
40+
print("lib/python%d.%d/site-packages" % sys.version_info[:2])
41+
elif os.name == "nt":
42+
print("Lib\\site-packages")
4243
else:
4344
raise
4445
elif args.variable_name == "LLDB_PYTHON_EXE_RELATIVE_PATH":
@@ -57,16 +58,20 @@ def main():
5758
exe = os.path.realpath(exe)
5859
continue
5960
else:
60-
print("Could not find a relative path to sys.executable under sys.prefix", file=sys.stderr)
61+
print(
62+
"Could not find a relative path to sys.executable under sys.prefix",
63+
file=sys.stderr,
64+
)
6165
for e in tried:
6266
print("tried:", e, file=sys.stderr)
6367
print("realpath(sys.prefix):", prefix, file=sys.stderr)
6468
print("sys.prefix:", sys.prefix, file=sys.stderr)
6569
sys.exit(1)
6670
elif args.variable_name == "LLDB_PYTHON_EXT_SUFFIX":
67-
print(sysconfig.get_config_var('EXT_SUFFIX'))
71+
print(sysconfig.get_config_var("EXT_SUFFIX"))
6872
else:
6973
parser.error(f"unknown variable {args.variable_name}")
7074

71-
if __name__ == '__main__':
75+
76+
if __name__ == "__main__":
7277
main()

lldb/docs/conf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
4343
extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", "sphinx.ext.intersphinx"]
4444

45-
autodoc_default_options = {
46-
"special-members": True
47-
}
45+
autodoc_default_options = {"special-members": True}
4846

4947
# Unless we only generate the basic manpage we need the plugin for generating
5048
# the Python API documentation.
@@ -60,9 +58,7 @@
6058
try:
6159
import furo
6260
except ModuleNotFoundError:
63-
print(
64-
f"install sphinx furo theme with {sys.executable} -m pip install furo"
65-
)
61+
print(f"install sphinx furo theme with {sys.executable} -m pip install furo")
6662
# The theme to use for HTML and HTML Help pages. See the documentation for
6763
# a list of builtin themes.
6864
html_theme = "furo"

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,15 +2604,16 @@ def assertSuccess(self, obj, msg=None):
26042604
if not obj.Success():
26052605
error = obj.GetCString()
26062606
self.fail(self._formatMessage(msg, "'{}' is not success".format(error)))
2607+
26072608
"""Assert that an lldb.SBError is in the "failure" state."""
26082609

2609-
def assertFailure(self, obj, error_str = None, msg=None):
2610+
def assertFailure(self, obj, error_str=None, msg=None):
26102611
if obj.Success():
26112612
self.fail(self._formatMessage(msg, "Error not in a fail state"))
26122613

26132614
if error_str == None:
26142615
return
2615-
2616+
26162617
error = obj.GetCString()
26172618
self.assertEqual(error, error_str, msg)
26182619

lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,14 @@ def request_disconnect(self, terminateDebuggee=None):
649649
}
650650
return self.send_recv(command_dict)
651651

652-
def request_disassemble(self, memoryReference, offset=-50, instructionCount=200, resolveSymbols=True):
652+
def request_disassemble(
653+
self, memoryReference, offset=-50, instructionCount=200, resolveSymbols=True
654+
):
653655
args_dict = {
654656
"memoryReference": memoryReference,
655657
"offset": offset,
656658
"instructionCount": instructionCount,
657-
"resolveSymbols": resolveSymbols
659+
"resolveSymbols": resolveSymbols,
658660
}
659661
command_dict = {
660662
"command": "disassemble",

lldb/source/Interpreter/embedded_interpreter.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
23
if sys.version_info[0] < 3:
34
import __builtin__ as builtins
45
else:
@@ -18,10 +19,10 @@
1819
have_readline = False
1920
else:
2021
have_readline = True
21-
if 'libedit' in readline.__doc__:
22-
readline.parse_and_bind('bind ^I rl_complete')
22+
if "libedit" in readline.__doc__:
23+
readline.parse_and_bind("bind ^I rl_complete")
2324
else:
24-
readline.parse_and_bind('tab: complete')
25+
readline.parse_and_bind("tab: complete")
2526

2627
# When running one line, we might place the string to run in this string
2728
# in case it would be hard to correctly escape a string's contents
@@ -34,7 +35,8 @@ def get_terminal_size(fd):
3435
import fcntl
3536
import termios
3637
import struct
37-
hw = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
38+
39+
hw = struct.unpack("hh", fcntl.ioctl(fd, termios.TIOCGWINSZ, "1234"))
3840
except:
3941
hw = (0, 0)
4042
return hw
@@ -46,7 +48,7 @@ class LLDBExit(SystemExit):
4648

4749
def strip_and_check_exit(line):
4850
line = line.rstrip()
49-
if line in ('exit', 'quit'):
51+
if line in ("exit", "quit"):
5052
raise LLDBExit
5153
return line
5254

@@ -75,6 +77,7 @@ def run_python_interpreter(local_dict):
7577
if get_terminal_size(fd)[1] == 0:
7678
try:
7779
import termios
80+
7881
old = termios.tcgetattr(fd)
7982
if old[3] & termios.ECHO:
8083
# Need to turn off echoing and restore
@@ -86,7 +89,8 @@ def run_python_interpreter(local_dict):
8689
code.interact(
8790
banner="Python Interactive Interpreter. To exit, type 'quit()', 'exit()'.",
8891
readfunc=readfunc_stdio,
89-
local=local_dict)
92+
local=local_dict,
93+
)
9094
finally:
9195
termios.tcsetattr(fd, termios.TCSADRAIN, old)
9296
except:
@@ -96,18 +100,20 @@ def run_python_interpreter(local_dict):
96100
code.interact(
97101
banner="Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.",
98102
readfunc=readfunc_stdio,
99-
local=local_dict)
103+
local=local_dict,
104+
)
100105
else:
101106
# We have a real interactive terminal
102107
code.interact(
103108
banner="Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.",
104109
readfunc=readfunc,
105-
local=local_dict)
110+
local=local_dict,
111+
)
106112
except LLDBExit:
107113
pass
108114
except SystemExit as e:
109115
if e.code:
110-
print('Script exited with code %s' % e.code)
116+
print("Script exited with code %s" % e.code)
111117

112118

113119
def run_one_line(local_dict, input_string):
@@ -127,4 +133,4 @@ def run_one_line(local_dict, input_string):
127133
pass
128134
except SystemExit as e:
129135
if e.code:
130-
print('Script exited with code %s' % e.code)
136+
print("Script exited with code %s" % e.code)

0 commit comments

Comments
 (0)