FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Lint with darker (black) · krassowski/ipython@efdec6c · GitHub

Repository navigation

Commit efdec6c

Browse files
committed
Lint with darker (black)
1 parent 819df4e commit efdec6c

2 files changed

Lines changed: 38 additions & 26 deletions

File tree

‎IPython/core/debugger.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@
146146

147147

148148
if sys.version_info < (3, 13):
149+
149150
class OldPdb(PdbClosureBackport, _OldPdb):
150151
pass
152+
151153
else:
152154
OldPdb = _OldPdb
153155

‎IPython/core/debugger_backport.py‎

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
agrees to be bound by the terms and conditions of this License
5656
Agreement.
5757
"""
58+
5859
import sys
5960
import types
6061
import codeop
@@ -64,9 +65,9 @@
6465

6566
class PdbClosureBackport:
6667
def _exec_in_closure(self, source, globals, locals):
67-
""" Run source code in closure so code object created within source
68-
can find variables in locals correctly
69-
returns True if the source is executed, False otherwise
68+
"""Run source code in closure so code object created within source
69+
can find variables in locals correctly
70+
returns True if the source is executed, False otherwise
7071
"""
7172

7273
# Determine if the source should be executed in closure. Only when the
@@ -81,10 +82,7 @@ def _exec_in_closure(self, source, globals, locals):
8182
# copy it first to avoid modifying the original locals
8283
locals_copy = dict(locals)
8384

84-
locals_copy["__pdb_eval__"] = {
85-
"result": None,
86-
"write_back": {}
87-
}
85+
locals_copy["__pdb_eval__"] = {"result": None, "write_back": {}}
8886

8987
# If the source is an expression, we need to print its value
9088
try:
@@ -95,10 +93,13 @@ def _exec_in_closure(self, source, globals, locals):
9593
source = "__pdb_eval__['result'] = " + source
9694

9795
# Add write-back to update the locals
98-
source = ("try:\n" +
99-
textwrap.indent(source, " ") + "\n" +
100-
"finally:\n" +
101-
" __pdb_eval__['write_back'] = locals()")
96+
source = (
97+
"try:\n"
98+
+ textwrap.indent(source, " ")
99+
+ "\n"
100+
+ "finally:\n"
101+
+ " __pdb_eval__['write_back'] = locals()"
102+
)
102103

103104
# Build a closure source code with freevars from locals like:
104105
# def __pdb_outer():
@@ -107,13 +108,17 @@ def _exec_in_closure(self, source, globals, locals):
107108
# nonlocal var
108109
# <source>
109110
# return __pdb_scope.__code__
110-
source_with_closure = ("def __pdb_outer():\n" +
111-
"\n".join(f" {var} = None" for var in locals_copy) + "\n" +
112-
" def __pdb_scope():\n" +
113-
"\n".join(f" nonlocal {var}" for var in locals_copy) + "\n" +
114-
textwrap.indent(source, " ") + "\n" +
115-
" return __pdb_scope.__code__"
116-
)
111+
source_with_closure = (
112+
"def __pdb_outer():\n"
113+
+ "\n".join(f" {var} = None" for var in locals_copy)
114+
+ "\n"
115+
+ " def __pdb_scope():\n"
116+
+ "\n".join(f" nonlocal {var}" for var in locals_copy)
117+
+ "\n"
118+
+ textwrap.indent(source, " ")
119+
+ "\n"
120+
+ " return __pdb_scope.__code__"
121+
)
117122

118123
# Get the code object of __pdb_scope()
119124
# The exec fills locals_copy with the __pdb_outer() function and we can call
@@ -147,36 +152,41 @@ def _exec_in_closure(self, source, globals, locals):
147152
return True
148153

149154
def default(self, line):
150-
if line[:1] == '!': line = line[1:].strip()
155+
if line[:1] == "!":
156+
line = line[1:].strip()
151157
locals = self.curframe_locals
152158
globals = self.curframe.f_globals
153159
try:
154160
buffer = line
155-
if (code := codeop.compile_command(line + '\n', '<stdin>', 'single')) is None:
161+
if (
162+
code := codeop.compile_command(line + "\n", "<stdin>", "single")
163+
) is None:
156164
# Multi-line mode
157165
with self._disable_command_completion():
158166
buffer = line
159167
continue_prompt = "... "
160-
while (code := codeop.compile_command(buffer, '<stdin>', 'single')) is None:
168+
while (
169+
code := codeop.compile_command(buffer, "<stdin>", "single")
170+
) is None:
161171
if self.use_rawinput:
162172
try:
163173
line = input(continue_prompt)
164174
except (EOFError, KeyboardInterrupt):
165175
self.lastcmd = ""
166-
print('\n')
176+
print("\n")
167177
return
168178
else:
169179
self.stdout.write(continue_prompt)
170180
self.stdout.flush()
171181
line = self.stdin.readline()
172182
if not len(line):
173183
self.lastcmd = ""
174-
self.stdout.write('\n')
184+
self.stdout.write("\n")
175185
self.stdout.flush()
176186
return
177187
else:
178-
line = line.rstrip('\r\n')
179-
buffer += '\n' + line
188+
line = line.rstrip("\r\n")
189+
buffer += "\n" + line
180190
save_stdout = sys.stdout
181191
save_stdin = sys.stdin
182192
save_displayhook = sys.displayhook
@@ -191,4 +201,4 @@ def default(self, line):
191201
sys.stdin = save_stdin
192202
sys.displayhook = save_displayhook
193203
except:
194-
self._error_exc()
204+
self._error_exc()

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL